documentation.d.ts 3.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498884998850088501885028850388504885058850688507885088850988510885118851288513885148851588516885178851888519885208852188522885238852488525885268852788528885298853088531885328853388534885358853688537885388853988540885418854288543885448854588546885478854888549885508855188552885538855488555885568855788558885598856088561885628856388564885658856688567885688856988570885718857288573885748857588576885778857888579885808858188582885838858488585885868858788588885898859088591885928859388594885958859688597885988859988600886018860288603886048860588606886078860888609886108861188612886138861488615886168861788618886198862088621886228862388624886258862688627886288862988630886318863288633886348863588636886378863888639886408864188642886438864488645886468864788648886498865088651886528865388654886558865688657886588865988660886618866288663886648866588666886678866888669886708867188672886738867488675886768867788678886798868088681886828868388684886858868688687886888868988690886918869288693886948869588696886978869888699887008870188702887038870488705887068870788708887098871088711887128871388714887158871688717887188871988720887218872288723887248872588726887278872888729887308873188732887338873488735887368873788738887398874088741887428874388744887458874688747887488874988750887518875288753887548875588756887578875888759887608876188762887638876488765887668876788768887698877088771887728877388774887758877688777887788877988780887818878288783887848878588786887878878888789887908879188792887938879488795887968879788798887998880088801888028880388804888058880688807888088880988810888118881288813888148881588816888178881888819888208882188822888238882488825888268882788828888298883088831888328883388834888358883688837888388883988840888418884288843888448884588846888478884888849888508885188852888538885488855888568885788858888598886088861888628886388864888658886688867888688886988870888718887288873888748887588876888778887888879888808888188882888838888488885888868888788888888898889088891888928889388894888958889688897888988889988900889018890288903889048890588906889078890888909889108891188912889138891488915889168891788918889198892088921889228892388924889258892688927889288892988930889318893288933889348893588936889378893888939889408894188942889438894488945889468894788948889498895088951889528895388954889558895688957889588895988960889618896288963889648896588966889678896888969889708897188972889738897488975889768897788978889798898088981889828898388984889858898688987889888898988990889918899288993889948899588996889978899888999890008900189002890038900489005890068900789008890098901089011890128901389014890158901689017890188901989020890218902289023890248902589026890278902889029890308903189032890338903489035890368903789038890398904089041890428904389044890458904689047890488904989050890518905289053890548905589056890578905889059890608906189062890638906489065890668906789068890698907089071890728907389074890758907689077890788907989080890818908289083890848908589086890878908889089890908909189092890938909489095890968909789098890998910089101891028910389104891058910689107891088910989110891118911289113891148911589116891178911889119891208912189122891238912489125891268912789128891298913089131891328913389134891358913689137891388913989140891418914289143891448914589146891478914889149891508915189152891538915489155891568915789158891598916089161891628916389164891658916689167891688916989170891718917289173891748917589176891778917889179891808918189182891838918489185891868918789188891898919089191891928919389194891958919689197891988919989200892018920289203892048920589206892078920889209892108921189212892138921489215892168921789218892198922089221892228922389224892258922689227892288922989230892318923289233892348923589236892378923889239892408924189242892438924489245892468924789248892498925089251892528925389254892558925689257892588925989260892618926289263892648926589266892678926889269892708927189272892738927489275892768927789278892798928089281892828928389284892858928689287892888928989290892918929289293892948929589296892978929889299893008930189302893038930489305893068930789308893098931089311893128931389314893158931689317893188931989320893218932289323893248932589326893278932889329893308933189332893338933489335893368933789338893398934089341893428934389344893458934689347893488934989350893518935289353893548935589356893578935889359893608936189362893638936489365893668936789368893698937089371893728937389374893758937689377893788937989380893818938289383893848938589386893878938889389893908939189392893938939489395893968939789398893998940089401894028940389404894058940689407894088940989410894118941289413894148941589416894178941889419894208942189422894238942489425894268942789428894298943089431894328943389434894358943689437894388943989440894418944289443894448944589446894478944889449894508945189452894538945489455894568945789458894598946089461894628946389464894658946689467894688946989470894718947289473894748947589476894778947889479894808948189482894838948489485894868948789488894898949089491894928949389494894958949689497894988949989500895018950289503895048950589506895078950889509895108951189512895138951489515895168951789518895198952089521895228952389524895258952689527895288952989530895318953289533895348953589536895378953889539895408954189542895438954489545895468954789548895498955089551895528955389554895558955689557895588955989560895618956289563895648956589566895678956889569895708957189572895738957489575895768957789578895798958089581895828958389584895858958689587895888958989590895918959289593895948959589596895978959889599896008960189602896038960489605896068960789608896098961089611896128961389614896158961689617896188961989620896218962289623896248962589626896278962889629896308963189632896338963489635896368963789638896398964089641896428964389644896458964689647896488964989650896518965289653896548965589656896578965889659896608966189662896638966489665896668966789668896698967089671896728967389674896758967689677896788967989680896818968289683896848968589686896878968889689896908969189692896938969489695896968969789698896998970089701897028970389704897058970689707897088970989710897118971289713897148971589716897178971889719897208972189722897238972489725897268972789728897298973089731897328973389734897358973689737897388973989740897418974289743897448974589746897478974889749897508975189752897538975489755897568975789758897598976089761897628976389764897658976689767897688976989770897718977289773897748977589776897778977889779897808978189782897838978489785897868978789788897898979089791897928979389794897958979689797897988979989800898018980289803898048980589806898078980889809898108981189812898138981489815898168981789818898198982089821898228982389824898258982689827898288982989830898318983289833898348983589836898378983889839898408984189842898438984489845898468984789848898498985089851898528985389854898558985689857898588985989860898618986289863898648986589866898678986889869898708987189872898738987489875898768987789878898798988089881898828988389884898858988689887898888988989890898918989289893898948989589896898978989889899899008990189902899038990489905899068990789908899098991089911899128991389914899158991689917899188991989920899218992289923899248992589926899278992889929899308993189932899338993489935899368993789938899398994089941899428994389944899458994689947899488994989950899518995289953899548995589956899578995889959899608996189962899638996489965899668996789968899698997089971899728997389974899758997689977899788997989980899818998289983899848998589986899878998889989899908999189992899938999489995899968999789998899999000090001900029000390004900059000690007900089000990010900119001290013900149001590016900179001890019900209002190022900239002490025900269002790028900299003090031900329003390034900359003690037900389003990040900419004290043900449004590046900479004890049900509005190052900539005490055900569005790058900599006090061900629006390064900659006690067900689006990070900719007290073900749007590076900779007890079900809008190082900839008490085900869008790088900899009090091900929009390094900959009690097900989009990100901019010290103901049010590106901079010890109901109011190112901139011490115901169011790118901199012090121901229012390124901259012690127901289012990130901319013290133901349013590136901379013890139901409014190142901439014490145901469014790148901499015090151901529015390154901559015690157901589015990160901619016290163901649016590166901679016890169901709017190172901739017490175901769017790178901799018090181901829018390184901859018690187901889018990190901919019290193901949019590196901979019890199902009020190202902039020490205902069020790208902099021090211902129021390214902159021690217902189021990220902219022290223902249022590226902279022890229902309023190232902339023490235902369023790238902399024090241902429024390244902459024690247902489024990250902519025290253902549025590256902579025890259902609026190262902639026490265902669026790268902699027090271902729027390274902759027690277902789027990280902819028290283902849028590286902879028890289902909029190292902939029490295902969029790298902999030090301903029030390304903059030690307903089030990310903119031290313903149031590316903179031890319903209032190322903239032490325903269032790328903299033090331903329033390334903359033690337903389033990340903419034290343903449034590346903479034890349903509035190352903539035490355903569035790358903599036090361903629036390364903659036690367903689036990370903719037290373903749037590376903779037890379903809038190382903839038490385903869038790388903899039090391903929039390394903959039690397903989039990400904019040290403904049040590406904079040890409904109041190412904139041490415904169041790418904199042090421904229042390424904259042690427904289042990430904319043290433904349043590436904379043890439904409044190442904439044490445904469044790448904499045090451904529045390454904559045690457904589045990460904619046290463904649046590466904679046890469904709047190472904739047490475904769047790478904799048090481904829048390484904859048690487904889048990490904919049290493904949049590496904979049890499905009050190502905039050490505905069050790508905099051090511905129051390514905159051690517905189051990520905219052290523905249052590526905279052890529905309053190532905339053490535905369053790538905399054090541905429054390544905459054690547905489054990550905519055290553905549055590556905579055890559905609056190562905639056490565905669056790568905699057090571905729057390574905759057690577905789057990580905819058290583905849058590586905879058890589905909059190592905939059490595905969059790598905999060090601906029060390604906059060690607906089060990610906119061290613906149061590616906179061890619906209062190622906239062490625906269062790628906299063090631906329063390634906359063690637906389063990640906419064290643906449064590646906479064890649906509065190652906539065490655906569065790658906599066090661906629066390664906659066690667906689066990670906719067290673906749067590676906779067890679906809068190682906839068490685906869068790688906899069090691906929069390694906959069690697906989069990700907019070290703907049070590706907079070890709907109071190712907139071490715907169071790718907199072090721907229072390724907259072690727907289072990730907319073290733907349073590736907379073890739907409074190742907439074490745907469074790748907499075090751907529075390754907559075690757907589075990760907619076290763907649076590766907679076890769907709077190772907739077490775907769077790778907799078090781907829078390784907859078690787907889078990790907919079290793907949079590796907979079890799908009080190802908039080490805908069080790808908099081090811908129081390814908159081690817908189081990820908219082290823908249082590826908279082890829908309083190832908339083490835908369083790838908399084090841908429084390844908459084690847908489084990850908519085290853908549085590856908579085890859908609086190862908639086490865908669086790868908699087090871908729087390874908759087690877908789087990880908819088290883908849088590886908879088890889908909089190892908939089490895908969089790898908999090090901909029090390904909059090690907909089090990910909119091290913909149091590916909179091890919909209092190922909239092490925909269092790928909299093090931909329093390934909359093690937909389093990940909419094290943909449094590946909479094890949909509095190952909539095490955909569095790958909599096090961909629096390964909659096690967909689096990970909719097290973909749097590976909779097890979909809098190982909839098490985909869098790988909899099090991909929099390994909959099690997909989099991000910019100291003910049100591006910079100891009910109101191012910139101491015910169101791018910199102091021910229102391024910259102691027910289102991030910319103291033910349103591036910379103891039910409104191042910439104491045910469104791048910499105091051910529105391054910559105691057910589105991060910619106291063910649106591066910679106891069910709107191072910739107491075910769107791078910799108091081910829108391084910859108691087910889108991090910919109291093910949109591096910979109891099911009110191102911039110491105911069110791108911099111091111911129111391114911159111691117911189111991120911219112291123911249112591126911279112891129911309113191132911339113491135911369113791138911399114091141911429114391144911459114691147911489114991150911519115291153911549115591156911579115891159911609116191162911639116491165911669116791168911699117091171911729117391174911759117691177911789117991180911819118291183911849118591186911879118891189911909119191192911939119491195911969119791198911999120091201912029120391204912059120691207912089120991210912119121291213912149121591216912179121891219912209122191222912239122491225912269122791228912299123091231912329123391234912359123691237912389123991240912419124291243912449124591246912479124891249912509125191252912539125491255912569125791258912599126091261912629126391264912659126691267912689126991270912719127291273912749127591276912779127891279912809128191282912839128491285912869128791288912899129091291912929129391294912959129691297912989129991300913019130291303913049130591306913079130891309913109131191312913139131491315913169131791318913199132091321913229132391324913259132691327913289132991330913319133291333913349133591336913379133891339913409134191342913439134491345913469134791348913499135091351913529135391354913559135691357913589135991360913619136291363913649136591366913679136891369913709137191372913739137491375913769137791378913799138091381913829138391384913859138691387913889138991390913919139291393913949139591396913979139891399914009140191402914039140491405914069140791408914099141091411914129141391414914159141691417914189141991420914219142291423914249142591426914279142891429914309143191432914339143491435914369143791438914399144091441914429144391444914459144691447914489144991450914519145291453914549145591456914579145891459914609146191462914639146491465914669146791468914699147091471914729147391474914759147691477914789147991480914819148291483914849148591486914879148891489914909149191492914939149491495914969149791498914999150091501915029150391504915059150691507915089150991510915119151291513915149151591516915179151891519915209152191522915239152491525915269152791528915299153091531915329153391534915359153691537915389153991540915419154291543915449154591546915479154891549915509155191552915539155491555915569155791558915599156091561915629156391564915659156691567915689156991570915719157291573915749157591576915779157891579915809158191582915839158491585915869158791588915899159091591915929159391594915959159691597915989159991600916019160291603916049160591606916079160891609916109161191612916139161491615916169161791618916199162091621916229162391624916259162691627916289162991630916319163291633916349163591636916379163891639916409164191642916439164491645916469164791648916499165091651916529165391654916559165691657916589165991660916619166291663916649166591666916679166891669916709167191672916739167491675916769167791678916799168091681916829168391684916859168691687916889168991690916919169291693916949169591696916979169891699917009170191702917039170491705917069170791708917099171091711917129171391714917159171691717917189171991720917219172291723917249172591726917279172891729917309173191732917339173491735917369173791738917399174091741917429174391744917459174691747917489174991750917519175291753917549175591756917579175891759917609176191762917639176491765917669176791768917699177091771917729177391774917759177691777917789177991780917819178291783917849178591786917879178891789917909179191792917939179491795917969179791798917999180091801918029180391804918059180691807918089180991810918119181291813918149181591816918179181891819918209182191822918239182491825918269182791828918299183091831918329183391834918359183691837918389183991840918419184291843918449184591846918479184891849918509185191852918539185491855918569185791858918599186091861918629186391864918659186691867918689186991870918719187291873918749187591876918779187891879918809188191882918839188491885918869188791888918899189091891918929189391894918959189691897918989189991900919019190291903919049190591906919079190891909919109191191912919139191491915919169191791918919199192091921919229192391924919259192691927919289192991930919319193291933919349193591936919379193891939919409194191942919439194491945919469194791948919499195091951919529195391954919559195691957919589195991960919619196291963919649196591966919679196891969919709197191972919739197491975919769197791978919799198091981919829198391984919859198691987919889198991990919919199291993919949199591996919979199891999920009200192002920039200492005920069200792008920099201092011920129201392014920159201692017920189201992020920219202292023920249202592026920279202892029920309203192032920339203492035920369203792038920399204092041920429204392044920459204692047920489204992050920519205292053920549205592056920579205892059920609206192062920639206492065920669206792068920699207092071920729207392074920759207692077920789207992080920819208292083920849208592086920879208892089920909209192092920939209492095920969209792098920999210092101921029210392104921059210692107921089210992110921119211292113921149211592116921179211892119921209212192122921239212492125921269212792128921299213092131921329213392134921359213692137921389213992140921419214292143921449214592146921479214892149921509215192152921539215492155921569215792158921599216092161921629216392164921659216692167921689216992170921719217292173921749217592176921779217892179921809218192182921839218492185921869218792188921899219092191921929219392194921959219692197921989219992200922019220292203922049220592206922079220892209922109221192212922139221492215922169221792218922199222092221922229222392224922259222692227922289222992230922319223292233922349223592236922379223892239922409224192242922439224492245922469224792248922499225092251922529225392254922559225692257922589225992260922619226292263922649226592266922679226892269922709227192272922739227492275922769227792278922799228092281922829228392284922859228692287922889228992290922919229292293922949229592296922979229892299923009230192302923039230492305923069230792308923099231092311923129231392314923159231692317923189231992320923219232292323923249232592326923279232892329923309233192332923339233492335923369233792338923399234092341923429234392344923459234692347923489234992350923519235292353923549235592356923579235892359923609236192362923639236492365923669236792368923699237092371923729237392374923759237692377923789237992380923819238292383923849238592386923879238892389923909239192392923939239492395923969239792398923999240092401924029240392404924059240692407924089240992410924119241292413924149241592416924179241892419924209242192422924239242492425924269242792428924299243092431924329243392434924359243692437924389243992440924419244292443924449244592446924479244892449924509245192452924539245492455924569245792458924599246092461924629246392464924659246692467924689246992470924719247292473924749247592476924779247892479924809248192482924839248492485924869248792488924899249092491924929249392494924959249692497924989249992500925019250292503925049250592506925079250892509925109251192512925139251492515925169251792518925199252092521925229252392524925259252692527925289252992530925319253292533925349253592536925379253892539925409254192542925439254492545925469254792548925499255092551925529255392554925559255692557925589255992560925619256292563925649256592566925679256892569925709257192572925739257492575925769257792578925799258092581925829258392584925859258692587925889258992590925919259292593925949259592596925979259892599926009260192602926039260492605926069260792608926099261092611926129261392614926159261692617926189261992620926219262292623926249262592626926279262892629926309263192632926339263492635926369263792638926399264092641926429264392644926459264692647926489264992650926519265292653926549265592656926579265892659926609266192662926639266492665926669266792668926699267092671926729267392674926759267692677926789267992680926819268292683926849268592686926879268892689926909269192692926939269492695926969269792698926999270092701927029270392704927059270692707927089270992710927119271292713927149271592716927179271892719927209272192722927239272492725927269272792728927299273092731927329273392734927359273692737927389273992740927419274292743927449274592746927479274892749927509275192752927539275492755927569275792758927599276092761927629276392764927659276692767927689276992770927719277292773927749277592776927779277892779927809278192782927839278492785927869278792788927899279092791927929279392794927959279692797927989279992800928019280292803928049280592806928079280892809928109281192812928139281492815928169281792818928199282092821928229282392824928259282692827928289282992830928319283292833928349283592836928379283892839928409284192842928439284492845928469284792848928499285092851928529285392854928559285692857928589285992860928619286292863928649286592866928679286892869928709287192872928739287492875928769287792878928799288092881928829288392884928859288692887928889288992890928919289292893928949289592896928979289892899929009290192902929039290492905929069290792908929099291092911929129291392914929159291692917929189291992920929219292292923929249292592926929279292892929929309293192932929339293492935929369293792938929399294092941929429294392944929459294692947929489294992950929519295292953929549295592956929579295892959929609296192962929639296492965929669296792968929699297092971929729297392974929759297692977929789297992980929819298292983929849298592986929879298892989929909299192992929939299492995929969299792998929999300093001930029300393004930059300693007930089300993010930119301293013930149301593016930179301893019930209302193022930239302493025930269302793028930299303093031930329303393034930359303693037930389303993040930419304293043930449304593046930479304893049930509305193052930539305493055930569305793058930599306093061930629306393064930659306693067930689306993070930719307293073930749307593076930779307893079930809308193082930839308493085930869308793088930899309093091930929309393094930959309693097930989309993100931019310293103931049310593106931079310893109931109311193112931139311493115931169311793118931199312093121931229312393124931259312693127931289312993130931319313293133931349313593136931379313893139931409314193142931439314493145931469314793148931499315093151931529315393154931559315693157931589315993160931619316293163931649316593166931679316893169931709317193172931739317493175931769317793178931799318093181931829318393184931859318693187931889318993190931919319293193931949319593196931979319893199932009320193202932039320493205932069320793208932099321093211932129321393214932159321693217932189321993220932219322293223932249322593226
  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 RBG 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. }
  24893. declare module BABYLON {
  24894. /**
  24895. * Manage the touch inputs to control the movement of a free camera.
  24896. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24897. */
  24898. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24899. /**
  24900. * Define if mouse events can be treated as touch events
  24901. */
  24902. allowMouse: boolean;
  24903. /**
  24904. * Defines the camera the input is attached to.
  24905. */
  24906. camera: FreeCamera;
  24907. /**
  24908. * Defines the touch sensibility for rotation.
  24909. * The higher the faster.
  24910. */
  24911. touchAngularSensibility: number;
  24912. /**
  24913. * Defines the touch sensibility for move.
  24914. * The higher the faster.
  24915. */
  24916. touchMoveSensibility: number;
  24917. private _offsetX;
  24918. private _offsetY;
  24919. private _pointerPressed;
  24920. private _pointerInput?;
  24921. private _observer;
  24922. private _onLostFocus;
  24923. /**
  24924. * Manage the touch inputs to control the movement of a free camera.
  24925. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24926. * @param allowMouse Defines if mouse events can be treated as touch events
  24927. */
  24928. constructor(
  24929. /**
  24930. * Define if mouse events can be treated as touch events
  24931. */
  24932. allowMouse?: boolean);
  24933. /**
  24934. * Attach the input controls to a specific dom element to get the input from.
  24935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24936. */
  24937. attachControl(noPreventDefault?: boolean): void;
  24938. /**
  24939. * Detach the current controls from the specified dom element.
  24940. */
  24941. detachControl(): void;
  24942. /**
  24943. * Update the current camera state depending on the inputs that have been used this frame.
  24944. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24945. */
  24946. checkInputs(): void;
  24947. /**
  24948. * Gets the class name of the current intput.
  24949. * @returns the class name
  24950. */
  24951. getClassName(): string;
  24952. /**
  24953. * Get the friendly name associated with the input class.
  24954. * @returns the input friendly name
  24955. */
  24956. getSimpleName(): string;
  24957. }
  24958. }
  24959. declare module BABYLON {
  24960. /**
  24961. * Default Inputs manager for the FreeCamera.
  24962. * It groups all the default supported inputs for ease of use.
  24963. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24964. */
  24965. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24966. /**
  24967. * @hidden
  24968. */
  24969. _mouseInput: Nullable<FreeCameraMouseInput>;
  24970. /**
  24971. * @hidden
  24972. */
  24973. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  24974. /**
  24975. * Instantiates a new FreeCameraInputsManager.
  24976. * @param camera Defines the camera the inputs belong to
  24977. */
  24978. constructor(camera: FreeCamera);
  24979. /**
  24980. * Add keyboard input support to the input manager.
  24981. * @returns the current input manager
  24982. */
  24983. addKeyboard(): FreeCameraInputsManager;
  24984. /**
  24985. * Add mouse input support to the input manager.
  24986. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  24987. * @returns the current input manager
  24988. */
  24989. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  24990. /**
  24991. * Removes the mouse input support from the manager
  24992. * @returns the current input manager
  24993. */
  24994. removeMouse(): FreeCameraInputsManager;
  24995. /**
  24996. * Add mouse wheel input support to the input manager.
  24997. * @returns the current input manager
  24998. */
  24999. addMouseWheel(): FreeCameraInputsManager;
  25000. /**
  25001. * Removes the mouse wheel input support from the manager
  25002. * @returns the current input manager
  25003. */
  25004. removeMouseWheel(): FreeCameraInputsManager;
  25005. /**
  25006. * Add touch input support to the input manager.
  25007. * @returns the current input manager
  25008. */
  25009. addTouch(): FreeCameraInputsManager;
  25010. /**
  25011. * Remove all attached input methods from a camera
  25012. */
  25013. clear(): void;
  25014. }
  25015. }
  25016. declare module BABYLON {
  25017. /**
  25018. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25019. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25020. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25021. */
  25022. export class FreeCamera extends TargetCamera {
  25023. /**
  25024. * Define the collision ellipsoid of the camera.
  25025. * This is helpful to simulate a camera body like the player body around the camera
  25026. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25027. */
  25028. ellipsoid: Vector3;
  25029. /**
  25030. * Define an offset for the position of the ellipsoid around the camera.
  25031. * This can be helpful to determine the center of the body near the gravity center of the body
  25032. * instead of its head.
  25033. */
  25034. ellipsoidOffset: Vector3;
  25035. /**
  25036. * Enable or disable collisions of the camera with the rest of the scene objects.
  25037. */
  25038. checkCollisions: boolean;
  25039. /**
  25040. * Enable or disable gravity on the camera.
  25041. */
  25042. applyGravity: boolean;
  25043. /**
  25044. * Define the input manager associated to the camera.
  25045. */
  25046. inputs: FreeCameraInputsManager;
  25047. /**
  25048. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25049. * Higher values reduce sensitivity.
  25050. */
  25051. get angularSensibility(): number;
  25052. /**
  25053. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25054. * Higher values reduce sensitivity.
  25055. */
  25056. set angularSensibility(value: number);
  25057. /**
  25058. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25059. */
  25060. get keysUp(): number[];
  25061. set keysUp(value: number[]);
  25062. /**
  25063. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25064. */
  25065. get keysUpward(): number[];
  25066. set keysUpward(value: number[]);
  25067. /**
  25068. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25069. */
  25070. get keysDown(): number[];
  25071. set keysDown(value: number[]);
  25072. /**
  25073. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25074. */
  25075. get keysDownward(): number[];
  25076. set keysDownward(value: number[]);
  25077. /**
  25078. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25079. */
  25080. get keysLeft(): number[];
  25081. set keysLeft(value: number[]);
  25082. /**
  25083. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25084. */
  25085. get keysRight(): number[];
  25086. set keysRight(value: number[]);
  25087. /**
  25088. * Event raised when the camera collide with a mesh in the scene.
  25089. */
  25090. onCollide: (collidedMesh: AbstractMesh) => void;
  25091. private _collider;
  25092. private _needMoveForGravity;
  25093. private _oldPosition;
  25094. private _diffPosition;
  25095. private _newPosition;
  25096. /** @hidden */
  25097. _localDirection: Vector3;
  25098. /** @hidden */
  25099. _transformedDirection: Vector3;
  25100. /**
  25101. * Instantiates a Free Camera.
  25102. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25103. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25104. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25105. * @param name Define the name of the camera in the scene
  25106. * @param position Define the start position of the camera in the scene
  25107. * @param scene Define the scene the camera belongs to
  25108. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25109. */
  25110. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25111. /**
  25112. * Attach the input controls to a specific dom element to get the input from.
  25113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25114. */
  25115. attachControl(noPreventDefault?: boolean): void;
  25116. /**
  25117. * Attach the input controls to a specific dom element to get the input from.
  25118. * @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
  25119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25120. * BACK COMPAT SIGNATURE ONLY.
  25121. */
  25122. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25123. /**
  25124. * Detach the current controls from the specified dom element.
  25125. */
  25126. detachControl(): void;
  25127. /**
  25128. * Detach the current controls from the specified dom element.
  25129. * @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
  25130. */
  25131. detachControl(ignored: any): void;
  25132. private _collisionMask;
  25133. /**
  25134. * Define a collision mask to limit the list of object the camera can collide with
  25135. */
  25136. get collisionMask(): number;
  25137. set collisionMask(mask: number);
  25138. /** @hidden */
  25139. _collideWithWorld(displacement: Vector3): void;
  25140. private _onCollisionPositionChange;
  25141. /** @hidden */
  25142. _checkInputs(): void;
  25143. /** @hidden */
  25144. _decideIfNeedsToMove(): boolean;
  25145. /** @hidden */
  25146. _updatePosition(): void;
  25147. /**
  25148. * Destroy the camera and release the current resources hold by it.
  25149. */
  25150. dispose(): void;
  25151. /**
  25152. * Gets the current object class name.
  25153. * @return the class name
  25154. */
  25155. getClassName(): string;
  25156. }
  25157. }
  25158. declare module BABYLON {
  25159. /**
  25160. * Represents a gamepad control stick position
  25161. */
  25162. export class StickValues {
  25163. /**
  25164. * The x component of the control stick
  25165. */
  25166. x: number;
  25167. /**
  25168. * The y component of the control stick
  25169. */
  25170. y: number;
  25171. /**
  25172. * Initializes the gamepad x and y control stick values
  25173. * @param x The x component of the gamepad control stick value
  25174. * @param y The y component of the gamepad control stick value
  25175. */
  25176. constructor(
  25177. /**
  25178. * The x component of the control stick
  25179. */
  25180. x: number,
  25181. /**
  25182. * The y component of the control stick
  25183. */
  25184. y: number);
  25185. }
  25186. /**
  25187. * An interface which manages callbacks for gamepad button changes
  25188. */
  25189. export interface GamepadButtonChanges {
  25190. /**
  25191. * Called when a gamepad has been changed
  25192. */
  25193. changed: boolean;
  25194. /**
  25195. * Called when a gamepad press event has been triggered
  25196. */
  25197. pressChanged: boolean;
  25198. /**
  25199. * Called when a touch event has been triggered
  25200. */
  25201. touchChanged: boolean;
  25202. /**
  25203. * Called when a value has changed
  25204. */
  25205. valueChanged: boolean;
  25206. }
  25207. /**
  25208. * Represents a gamepad
  25209. */
  25210. export class Gamepad {
  25211. /**
  25212. * The id of the gamepad
  25213. */
  25214. id: string;
  25215. /**
  25216. * The index of the gamepad
  25217. */
  25218. index: number;
  25219. /**
  25220. * The browser gamepad
  25221. */
  25222. browserGamepad: any;
  25223. /**
  25224. * Specifies what type of gamepad this represents
  25225. */
  25226. type: number;
  25227. private _leftStick;
  25228. private _rightStick;
  25229. /** @hidden */
  25230. _isConnected: boolean;
  25231. private _leftStickAxisX;
  25232. private _leftStickAxisY;
  25233. private _rightStickAxisX;
  25234. private _rightStickAxisY;
  25235. /**
  25236. * Triggered when the left control stick has been changed
  25237. */
  25238. private _onleftstickchanged;
  25239. /**
  25240. * Triggered when the right control stick has been changed
  25241. */
  25242. private _onrightstickchanged;
  25243. /**
  25244. * Represents a gamepad controller
  25245. */
  25246. static GAMEPAD: number;
  25247. /**
  25248. * Represents a generic controller
  25249. */
  25250. static GENERIC: number;
  25251. /**
  25252. * Represents an XBox controller
  25253. */
  25254. static XBOX: number;
  25255. /**
  25256. * Represents a pose-enabled controller
  25257. */
  25258. static POSE_ENABLED: number;
  25259. /**
  25260. * Represents an Dual Shock controller
  25261. */
  25262. static DUALSHOCK: number;
  25263. /**
  25264. * Specifies whether the left control stick should be Y-inverted
  25265. */
  25266. protected _invertLeftStickY: boolean;
  25267. /**
  25268. * Specifies if the gamepad has been connected
  25269. */
  25270. get isConnected(): boolean;
  25271. /**
  25272. * Initializes the gamepad
  25273. * @param id The id of the gamepad
  25274. * @param index The index of the gamepad
  25275. * @param browserGamepad The browser gamepad
  25276. * @param leftStickX The x component of the left joystick
  25277. * @param leftStickY The y component of the left joystick
  25278. * @param rightStickX The x component of the right joystick
  25279. * @param rightStickY The y component of the right joystick
  25280. */
  25281. constructor(
  25282. /**
  25283. * The id of the gamepad
  25284. */
  25285. id: string,
  25286. /**
  25287. * The index of the gamepad
  25288. */
  25289. index: number,
  25290. /**
  25291. * The browser gamepad
  25292. */
  25293. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25294. /**
  25295. * Callback triggered when the left joystick has changed
  25296. * @param callback
  25297. */
  25298. onleftstickchanged(callback: (values: StickValues) => void): void;
  25299. /**
  25300. * Callback triggered when the right joystick has changed
  25301. * @param callback
  25302. */
  25303. onrightstickchanged(callback: (values: StickValues) => void): void;
  25304. /**
  25305. * Gets the left joystick
  25306. */
  25307. get leftStick(): StickValues;
  25308. /**
  25309. * Sets the left joystick values
  25310. */
  25311. set leftStick(newValues: StickValues);
  25312. /**
  25313. * Gets the right joystick
  25314. */
  25315. get rightStick(): StickValues;
  25316. /**
  25317. * Sets the right joystick value
  25318. */
  25319. set rightStick(newValues: StickValues);
  25320. /**
  25321. * Updates the gamepad joystick positions
  25322. */
  25323. update(): void;
  25324. /**
  25325. * Disposes the gamepad
  25326. */
  25327. dispose(): void;
  25328. }
  25329. /**
  25330. * Represents a generic gamepad
  25331. */
  25332. export class GenericPad extends Gamepad {
  25333. private _buttons;
  25334. private _onbuttondown;
  25335. private _onbuttonup;
  25336. /**
  25337. * Observable triggered when a button has been pressed
  25338. */
  25339. onButtonDownObservable: Observable<number>;
  25340. /**
  25341. * Observable triggered when a button has been released
  25342. */
  25343. onButtonUpObservable: Observable<number>;
  25344. /**
  25345. * Callback triggered when a button has been pressed
  25346. * @param callback Called when a button has been pressed
  25347. */
  25348. onbuttondown(callback: (buttonPressed: number) => void): void;
  25349. /**
  25350. * Callback triggered when a button has been released
  25351. * @param callback Called when a button has been released
  25352. */
  25353. onbuttonup(callback: (buttonReleased: number) => void): void;
  25354. /**
  25355. * Initializes the generic gamepad
  25356. * @param id The id of the generic gamepad
  25357. * @param index The index of the generic gamepad
  25358. * @param browserGamepad The browser gamepad
  25359. */
  25360. constructor(id: string, index: number, browserGamepad: any);
  25361. private _setButtonValue;
  25362. /**
  25363. * Updates the generic gamepad
  25364. */
  25365. update(): void;
  25366. /**
  25367. * Disposes the generic gamepad
  25368. */
  25369. dispose(): void;
  25370. }
  25371. }
  25372. declare module BABYLON {
  25373. /**
  25374. * Defines a runtime animation
  25375. */
  25376. export class RuntimeAnimation {
  25377. private _events;
  25378. /**
  25379. * The current frame of the runtime animation
  25380. */
  25381. private _currentFrame;
  25382. /**
  25383. * The animation used by the runtime animation
  25384. */
  25385. private _animation;
  25386. /**
  25387. * The target of the runtime animation
  25388. */
  25389. private _target;
  25390. /**
  25391. * The initiating animatable
  25392. */
  25393. private _host;
  25394. /**
  25395. * The original value of the runtime animation
  25396. */
  25397. private _originalValue;
  25398. /**
  25399. * The original blend value of the runtime animation
  25400. */
  25401. private _originalBlendValue;
  25402. /**
  25403. * The offsets cache of the runtime animation
  25404. */
  25405. private _offsetsCache;
  25406. /**
  25407. * The high limits cache of the runtime animation
  25408. */
  25409. private _highLimitsCache;
  25410. /**
  25411. * Specifies if the runtime animation has been stopped
  25412. */
  25413. private _stopped;
  25414. /**
  25415. * The blending factor of the runtime animation
  25416. */
  25417. private _blendingFactor;
  25418. /**
  25419. * The BabylonJS scene
  25420. */
  25421. private _scene;
  25422. /**
  25423. * The current value of the runtime animation
  25424. */
  25425. private _currentValue;
  25426. /** @hidden */
  25427. _animationState: _IAnimationState;
  25428. /**
  25429. * The active target of the runtime animation
  25430. */
  25431. private _activeTargets;
  25432. private _currentActiveTarget;
  25433. private _directTarget;
  25434. /**
  25435. * The target path of the runtime animation
  25436. */
  25437. private _targetPath;
  25438. /**
  25439. * The weight of the runtime animation
  25440. */
  25441. private _weight;
  25442. /**
  25443. * The ratio offset of the runtime animation
  25444. */
  25445. private _ratioOffset;
  25446. /**
  25447. * The previous delay of the runtime animation
  25448. */
  25449. private _previousDelay;
  25450. /**
  25451. * The previous ratio of the runtime animation
  25452. */
  25453. private _previousRatio;
  25454. private _enableBlending;
  25455. private _keys;
  25456. private _minFrame;
  25457. private _maxFrame;
  25458. private _minValue;
  25459. private _maxValue;
  25460. private _targetIsArray;
  25461. /**
  25462. * Gets the current frame of the runtime animation
  25463. */
  25464. get currentFrame(): number;
  25465. /**
  25466. * Gets the weight of the runtime animation
  25467. */
  25468. get weight(): number;
  25469. /**
  25470. * Gets the current value of the runtime animation
  25471. */
  25472. get currentValue(): any;
  25473. /**
  25474. * Gets the target path of the runtime animation
  25475. */
  25476. get targetPath(): string;
  25477. /**
  25478. * Gets the actual target of the runtime animation
  25479. */
  25480. get target(): any;
  25481. /**
  25482. * Gets the additive state of the runtime animation
  25483. */
  25484. get isAdditive(): boolean;
  25485. /** @hidden */
  25486. _onLoop: () => void;
  25487. /**
  25488. * Create a new RuntimeAnimation object
  25489. * @param target defines the target of the animation
  25490. * @param animation defines the source animation object
  25491. * @param scene defines the hosting scene
  25492. * @param host defines the initiating Animatable
  25493. */
  25494. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25495. private _preparePath;
  25496. /**
  25497. * Gets the animation from the runtime animation
  25498. */
  25499. get animation(): Animation;
  25500. /**
  25501. * Resets the runtime animation to the beginning
  25502. * @param restoreOriginal defines whether to restore the target property to the original value
  25503. */
  25504. reset(restoreOriginal?: boolean): void;
  25505. /**
  25506. * Specifies if the runtime animation is stopped
  25507. * @returns Boolean specifying if the runtime animation is stopped
  25508. */
  25509. isStopped(): boolean;
  25510. /**
  25511. * Disposes of the runtime animation
  25512. */
  25513. dispose(): void;
  25514. /**
  25515. * Apply the interpolated value to the target
  25516. * @param currentValue defines the value computed by the animation
  25517. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25518. */
  25519. setValue(currentValue: any, weight: number): void;
  25520. private _getOriginalValues;
  25521. private _setValue;
  25522. /**
  25523. * Gets the loop pmode of the runtime animation
  25524. * @returns Loop Mode
  25525. */
  25526. private _getCorrectLoopMode;
  25527. /**
  25528. * Move the current animation to a given frame
  25529. * @param frame defines the frame to move to
  25530. */
  25531. goToFrame(frame: number): void;
  25532. /**
  25533. * @hidden Internal use only
  25534. */
  25535. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25536. /**
  25537. * Execute the current animation
  25538. * @param delay defines the delay to add to the current frame
  25539. * @param from defines the lower bound of the animation range
  25540. * @param to defines the upper bound of the animation range
  25541. * @param loop defines if the current animation must loop
  25542. * @param speedRatio defines the current speed ratio
  25543. * @param weight defines the weight of the animation (default is -1 so no weight)
  25544. * @param onLoop optional callback called when animation loops
  25545. * @returns a boolean indicating if the animation is running
  25546. */
  25547. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25548. }
  25549. }
  25550. declare module BABYLON {
  25551. /**
  25552. * Class used to store an actual running animation
  25553. */
  25554. export class Animatable {
  25555. /** defines the target object */
  25556. target: any;
  25557. /** defines the starting frame number (default is 0) */
  25558. fromFrame: number;
  25559. /** defines the ending frame number (default is 100) */
  25560. toFrame: number;
  25561. /** defines if the animation must loop (default is false) */
  25562. loopAnimation: boolean;
  25563. /** defines a callback to call when animation ends if it is not looping */
  25564. onAnimationEnd?: (() => void) | null | undefined;
  25565. /** defines a callback to call when animation loops */
  25566. onAnimationLoop?: (() => void) | null | undefined;
  25567. /** defines whether the animation should be evaluated additively */
  25568. isAdditive: boolean;
  25569. private _localDelayOffset;
  25570. private _pausedDelay;
  25571. private _runtimeAnimations;
  25572. private _paused;
  25573. private _scene;
  25574. private _speedRatio;
  25575. private _weight;
  25576. private _syncRoot;
  25577. /**
  25578. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25579. * This will only apply for non looping animation (default is true)
  25580. */
  25581. disposeOnEnd: boolean;
  25582. /**
  25583. * Gets a boolean indicating if the animation has started
  25584. */
  25585. animationStarted: boolean;
  25586. /**
  25587. * Observer raised when the animation ends
  25588. */
  25589. onAnimationEndObservable: Observable<Animatable>;
  25590. /**
  25591. * Observer raised when the animation loops
  25592. */
  25593. onAnimationLoopObservable: Observable<Animatable>;
  25594. /**
  25595. * Gets the root Animatable used to synchronize and normalize animations
  25596. */
  25597. get syncRoot(): Nullable<Animatable>;
  25598. /**
  25599. * Gets the current frame of the first RuntimeAnimation
  25600. * Used to synchronize Animatables
  25601. */
  25602. get masterFrame(): number;
  25603. /**
  25604. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25605. */
  25606. get weight(): number;
  25607. set weight(value: number);
  25608. /**
  25609. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25610. */
  25611. get speedRatio(): number;
  25612. set speedRatio(value: number);
  25613. /**
  25614. * Creates a new Animatable
  25615. * @param scene defines the hosting scene
  25616. * @param target defines the target object
  25617. * @param fromFrame defines the starting frame number (default is 0)
  25618. * @param toFrame defines the ending frame number (default is 100)
  25619. * @param loopAnimation defines if the animation must loop (default is false)
  25620. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25621. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25622. * @param animations defines a group of animation to add to the new Animatable
  25623. * @param onAnimationLoop defines a callback to call when animation loops
  25624. * @param isAdditive defines whether the animation should be evaluated additively
  25625. */
  25626. constructor(scene: Scene,
  25627. /** defines the target object */
  25628. target: any,
  25629. /** defines the starting frame number (default is 0) */
  25630. fromFrame?: number,
  25631. /** defines the ending frame number (default is 100) */
  25632. toFrame?: number,
  25633. /** defines if the animation must loop (default is false) */
  25634. loopAnimation?: boolean, speedRatio?: number,
  25635. /** defines a callback to call when animation ends if it is not looping */
  25636. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25637. /** defines a callback to call when animation loops */
  25638. onAnimationLoop?: (() => void) | null | undefined,
  25639. /** defines whether the animation should be evaluated additively */
  25640. isAdditive?: boolean);
  25641. /**
  25642. * Synchronize and normalize current Animatable with a source Animatable
  25643. * This is useful when using animation weights and when animations are not of the same length
  25644. * @param root defines the root Animatable to synchronize with
  25645. * @returns the current Animatable
  25646. */
  25647. syncWith(root: Animatable): Animatable;
  25648. /**
  25649. * Gets the list of runtime animations
  25650. * @returns an array of RuntimeAnimation
  25651. */
  25652. getAnimations(): RuntimeAnimation[];
  25653. /**
  25654. * Adds more animations to the current animatable
  25655. * @param target defines the target of the animations
  25656. * @param animations defines the new animations to add
  25657. */
  25658. appendAnimations(target: any, animations: Animation[]): void;
  25659. /**
  25660. * Gets the source animation for a specific property
  25661. * @param property defines the propertyu to look for
  25662. * @returns null or the source animation for the given property
  25663. */
  25664. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25665. /**
  25666. * Gets the runtime animation for a specific property
  25667. * @param property defines the propertyu to look for
  25668. * @returns null or the runtime animation for the given property
  25669. */
  25670. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25671. /**
  25672. * Resets the animatable to its original state
  25673. */
  25674. reset(): void;
  25675. /**
  25676. * Allows the animatable to blend with current running animations
  25677. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25678. * @param blendingSpeed defines the blending speed to use
  25679. */
  25680. enableBlending(blendingSpeed: number): void;
  25681. /**
  25682. * Disable animation blending
  25683. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25684. */
  25685. disableBlending(): void;
  25686. /**
  25687. * Jump directly to a given frame
  25688. * @param frame defines the frame to jump to
  25689. */
  25690. goToFrame(frame: number): void;
  25691. /**
  25692. * Pause the animation
  25693. */
  25694. pause(): void;
  25695. /**
  25696. * Restart the animation
  25697. */
  25698. restart(): void;
  25699. private _raiseOnAnimationEnd;
  25700. /**
  25701. * Stop and delete the current animation
  25702. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25703. * @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)
  25704. */
  25705. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25706. /**
  25707. * Wait asynchronously for the animation to end
  25708. * @returns a promise which will be fullfilled when the animation ends
  25709. */
  25710. waitAsync(): Promise<Animatable>;
  25711. /** @hidden */
  25712. _animate(delay: number): boolean;
  25713. }
  25714. interface Scene {
  25715. /** @hidden */
  25716. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25717. /** @hidden */
  25718. _processLateAnimationBindingsForMatrices(holder: {
  25719. totalWeight: number;
  25720. totalAdditiveWeight: number;
  25721. animations: RuntimeAnimation[];
  25722. additiveAnimations: RuntimeAnimation[];
  25723. originalValue: Matrix;
  25724. }): any;
  25725. /** @hidden */
  25726. _processLateAnimationBindingsForQuaternions(holder: {
  25727. totalWeight: number;
  25728. totalAdditiveWeight: number;
  25729. animations: RuntimeAnimation[];
  25730. additiveAnimations: RuntimeAnimation[];
  25731. originalValue: Quaternion;
  25732. }, refQuaternion: Quaternion): Quaternion;
  25733. /** @hidden */
  25734. _processLateAnimationBindings(): void;
  25735. /**
  25736. * Will start the animation sequence of a given target
  25737. * @param target defines the target
  25738. * @param from defines from which frame should animation start
  25739. * @param to defines until which frame should animation run.
  25740. * @param weight defines the weight to apply to the animation (1.0 by default)
  25741. * @param loop defines if the animation loops
  25742. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25743. * @param onAnimationEnd defines the function to be executed when the animation ends
  25744. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25745. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25746. * @param onAnimationLoop defines the callback to call when an animation loops
  25747. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25748. * @returns the animatable object created for this animation
  25749. */
  25750. 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;
  25751. /**
  25752. * Will start the animation sequence of a given target
  25753. * @param target defines the target
  25754. * @param from defines from which frame should animation start
  25755. * @param to defines until which frame should animation run.
  25756. * @param loop defines if the animation loops
  25757. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25758. * @param onAnimationEnd defines the function to be executed when the animation ends
  25759. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25760. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25761. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25762. * @param onAnimationLoop defines the callback to call when an animation loops
  25763. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25764. * @returns the animatable object created for this animation
  25765. */
  25766. 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;
  25767. /**
  25768. * Will start the animation sequence of a given target and its hierarchy
  25769. * @param target defines the target
  25770. * @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.
  25771. * @param from defines from which frame should animation start
  25772. * @param to defines until which frame should animation run.
  25773. * @param loop defines if the animation loops
  25774. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25775. * @param onAnimationEnd defines the function to be executed when the animation ends
  25776. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25777. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25778. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25779. * @param onAnimationLoop defines the callback to call when an animation loops
  25780. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25781. * @returns the list of created animatables
  25782. */
  25783. 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[];
  25784. /**
  25785. * Begin a new animation on a given node
  25786. * @param target defines the target where the animation will take place
  25787. * @param animations defines the list of animations to start
  25788. * @param from defines the initial value
  25789. * @param to defines the final value
  25790. * @param loop defines if you want animation to loop (off by default)
  25791. * @param speedRatio defines the speed ratio to apply to all animations
  25792. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25793. * @param onAnimationLoop defines the callback to call when an animation loops
  25794. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25795. * @returns the list of created animatables
  25796. */
  25797. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25798. /**
  25799. * Begin a new animation on a given node and its hierarchy
  25800. * @param target defines the root node where the animation will take place
  25801. * @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.
  25802. * @param animations defines the list of animations to start
  25803. * @param from defines the initial value
  25804. * @param to defines the final value
  25805. * @param loop defines if you want animation to loop (off by default)
  25806. * @param speedRatio defines the speed ratio to apply to all animations
  25807. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25808. * @param onAnimationLoop defines the callback to call when an animation loops
  25809. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25810. * @returns the list of animatables created for all nodes
  25811. */
  25812. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25813. /**
  25814. * Gets the animatable associated with a specific target
  25815. * @param target defines the target of the animatable
  25816. * @returns the required animatable if found
  25817. */
  25818. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25819. /**
  25820. * Gets all animatables associated with a given target
  25821. * @param target defines the target to look animatables for
  25822. * @returns an array of Animatables
  25823. */
  25824. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25825. /**
  25826. * Stops and removes all animations that have been applied to the scene
  25827. */
  25828. stopAllAnimations(): void;
  25829. /**
  25830. * Gets the current delta time used by animation engine
  25831. */
  25832. deltaTime: number;
  25833. }
  25834. interface Bone {
  25835. /**
  25836. * Copy an animation range from another bone
  25837. * @param source defines the source bone
  25838. * @param rangeName defines the range name to copy
  25839. * @param frameOffset defines the frame offset
  25840. * @param rescaleAsRequired defines if rescaling must be applied if required
  25841. * @param skelDimensionsRatio defines the scaling ratio
  25842. * @returns true if operation was successful
  25843. */
  25844. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25845. }
  25846. }
  25847. declare module BABYLON {
  25848. /**
  25849. * Class used to override all child animations of a given target
  25850. */
  25851. export class AnimationPropertiesOverride {
  25852. /**
  25853. * Gets or sets a value indicating if animation blending must be used
  25854. */
  25855. enableBlending: boolean;
  25856. /**
  25857. * Gets or sets the blending speed to use when enableBlending is true
  25858. */
  25859. blendingSpeed: number;
  25860. /**
  25861. * Gets or sets the default loop mode to use
  25862. */
  25863. loopMode: number;
  25864. }
  25865. }
  25866. declare module BABYLON {
  25867. /**
  25868. * Class used to handle skinning animations
  25869. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25870. */
  25871. export class Skeleton implements IAnimatable {
  25872. /** defines the skeleton name */
  25873. name: string;
  25874. /** defines the skeleton Id */
  25875. id: string;
  25876. /**
  25877. * Defines the list of child bones
  25878. */
  25879. bones: Bone[];
  25880. /**
  25881. * Defines an estimate of the dimension of the skeleton at rest
  25882. */
  25883. dimensionsAtRest: Vector3;
  25884. /**
  25885. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25886. */
  25887. needInitialSkinMatrix: boolean;
  25888. /**
  25889. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25890. */
  25891. overrideMesh: Nullable<AbstractMesh>;
  25892. /**
  25893. * Gets the list of animations attached to this skeleton
  25894. */
  25895. animations: Array<Animation>;
  25896. private _scene;
  25897. private _isDirty;
  25898. private _transformMatrices;
  25899. private _transformMatrixTexture;
  25900. private _meshesWithPoseMatrix;
  25901. private _animatables;
  25902. private _identity;
  25903. private _synchronizedWithMesh;
  25904. private _ranges;
  25905. private _lastAbsoluteTransformsUpdateId;
  25906. private _canUseTextureForBones;
  25907. private _uniqueId;
  25908. /** @hidden */
  25909. _numBonesWithLinkedTransformNode: number;
  25910. /** @hidden */
  25911. _hasWaitingData: Nullable<boolean>;
  25912. /** @hidden */
  25913. _waitingOverrideMeshId: Nullable<string>;
  25914. /**
  25915. * Specifies if the skeleton should be serialized
  25916. */
  25917. doNotSerialize: boolean;
  25918. private _useTextureToStoreBoneMatrices;
  25919. /**
  25920. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25921. * Please note that this option is not available if the hardware does not support it
  25922. */
  25923. get useTextureToStoreBoneMatrices(): boolean;
  25924. set useTextureToStoreBoneMatrices(value: boolean);
  25925. private _animationPropertiesOverride;
  25926. /**
  25927. * Gets or sets the animation properties override
  25928. */
  25929. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25930. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25931. /**
  25932. * List of inspectable custom properties (used by the Inspector)
  25933. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25934. */
  25935. inspectableCustomProperties: IInspectable[];
  25936. /**
  25937. * An observable triggered before computing the skeleton's matrices
  25938. */
  25939. onBeforeComputeObservable: Observable<Skeleton>;
  25940. /**
  25941. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25942. */
  25943. get isUsingTextureForMatrices(): boolean;
  25944. /**
  25945. * Gets the unique ID of this skeleton
  25946. */
  25947. get uniqueId(): number;
  25948. /**
  25949. * Creates a new skeleton
  25950. * @param name defines the skeleton name
  25951. * @param id defines the skeleton Id
  25952. * @param scene defines the hosting scene
  25953. */
  25954. constructor(
  25955. /** defines the skeleton name */
  25956. name: string,
  25957. /** defines the skeleton Id */
  25958. id: string, scene: Scene);
  25959. /**
  25960. * Gets the current object class name.
  25961. * @return the class name
  25962. */
  25963. getClassName(): string;
  25964. /**
  25965. * Returns an array containing the root bones
  25966. * @returns an array containing the root bones
  25967. */
  25968. getChildren(): Array<Bone>;
  25969. /**
  25970. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25971. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25972. * @returns a Float32Array containing matrices data
  25973. */
  25974. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25975. /**
  25976. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25977. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25978. * @returns a raw texture containing the data
  25979. */
  25980. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25981. /**
  25982. * Gets the current hosting scene
  25983. * @returns a scene object
  25984. */
  25985. getScene(): Scene;
  25986. /**
  25987. * Gets a string representing the current skeleton data
  25988. * @param fullDetails defines a boolean indicating if we want a verbose version
  25989. * @returns a string representing the current skeleton data
  25990. */
  25991. toString(fullDetails?: boolean): string;
  25992. /**
  25993. * Get bone's index searching by name
  25994. * @param name defines bone's name to search for
  25995. * @return the indice of the bone. Returns -1 if not found
  25996. */
  25997. getBoneIndexByName(name: string): number;
  25998. /**
  25999. * Creater a new animation range
  26000. * @param name defines the name of the range
  26001. * @param from defines the start key
  26002. * @param to defines the end key
  26003. */
  26004. createAnimationRange(name: string, from: number, to: number): void;
  26005. /**
  26006. * Delete a specific animation range
  26007. * @param name defines the name of the range
  26008. * @param deleteFrames defines if frames must be removed as well
  26009. */
  26010. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26011. /**
  26012. * Gets a specific animation range
  26013. * @param name defines the name of the range to look for
  26014. * @returns the requested animation range or null if not found
  26015. */
  26016. getAnimationRange(name: string): Nullable<AnimationRange>;
  26017. /**
  26018. * Gets the list of all animation ranges defined on this skeleton
  26019. * @returns an array
  26020. */
  26021. getAnimationRanges(): Nullable<AnimationRange>[];
  26022. /**
  26023. * Copy animation range from a source skeleton.
  26024. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26025. * @param source defines the source skeleton
  26026. * @param name defines the name of the range to copy
  26027. * @param rescaleAsRequired defines if rescaling must be applied if required
  26028. * @returns true if operation was successful
  26029. */
  26030. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26031. /**
  26032. * Forces the skeleton to go to rest pose
  26033. */
  26034. returnToRest(): void;
  26035. private _getHighestAnimationFrame;
  26036. /**
  26037. * Begin a specific animation range
  26038. * @param name defines the name of the range to start
  26039. * @param loop defines if looping must be turned on (false by default)
  26040. * @param speedRatio defines the speed ratio to apply (1 by default)
  26041. * @param onAnimationEnd defines a callback which will be called when animation will end
  26042. * @returns a new animatable
  26043. */
  26044. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26045. /**
  26046. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26047. * @param skeleton defines the Skeleton containing the animation range to convert
  26048. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26049. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26050. * @returns the original skeleton
  26051. */
  26052. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26053. /** @hidden */
  26054. _markAsDirty(): void;
  26055. /** @hidden */
  26056. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26057. /** @hidden */
  26058. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26059. private _computeTransformMatrices;
  26060. /**
  26061. * Build all resources required to render a skeleton
  26062. */
  26063. prepare(): void;
  26064. /**
  26065. * Gets the list of animatables currently running for this skeleton
  26066. * @returns an array of animatables
  26067. */
  26068. getAnimatables(): IAnimatable[];
  26069. /**
  26070. * Clone the current skeleton
  26071. * @param name defines the name of the new skeleton
  26072. * @param id defines the id of the new skeleton
  26073. * @returns the new skeleton
  26074. */
  26075. clone(name: string, id?: string): Skeleton;
  26076. /**
  26077. * Enable animation blending for this skeleton
  26078. * @param blendingSpeed defines the blending speed to apply
  26079. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26080. */
  26081. enableBlending(blendingSpeed?: number): void;
  26082. /**
  26083. * Releases all resources associated with the current skeleton
  26084. */
  26085. dispose(): void;
  26086. /**
  26087. * Serialize the skeleton in a JSON object
  26088. * @returns a JSON object
  26089. */
  26090. serialize(): any;
  26091. /**
  26092. * Creates a new skeleton from serialized data
  26093. * @param parsedSkeleton defines the serialized data
  26094. * @param scene defines the hosting scene
  26095. * @returns a new skeleton
  26096. */
  26097. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26098. /**
  26099. * Compute all node absolute transforms
  26100. * @param forceUpdate defines if computation must be done even if cache is up to date
  26101. */
  26102. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26103. /**
  26104. * Gets the root pose matrix
  26105. * @returns a matrix
  26106. */
  26107. getPoseMatrix(): Nullable<Matrix>;
  26108. /**
  26109. * Sorts bones per internal index
  26110. */
  26111. sortBones(): void;
  26112. private _sortBones;
  26113. /**
  26114. * Set the current local matrix as the restPose for all bones in the skeleton.
  26115. */
  26116. setCurrentPoseAsRest(): void;
  26117. }
  26118. }
  26119. declare module BABYLON {
  26120. /**
  26121. * Class used to store bone information
  26122. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26123. */
  26124. export class Bone extends Node {
  26125. /**
  26126. * defines the bone name
  26127. */
  26128. name: string;
  26129. private static _tmpVecs;
  26130. private static _tmpQuat;
  26131. private static _tmpMats;
  26132. /**
  26133. * Gets the list of child bones
  26134. */
  26135. children: Bone[];
  26136. /** Gets the animations associated with this bone */
  26137. animations: Animation[];
  26138. /**
  26139. * Gets or sets bone length
  26140. */
  26141. length: number;
  26142. /**
  26143. * @hidden Internal only
  26144. * Set this value to map this bone to a different index in the transform matrices
  26145. * Set this value to -1 to exclude the bone from the transform matrices
  26146. */
  26147. _index: Nullable<number>;
  26148. private _skeleton;
  26149. private _localMatrix;
  26150. private _restPose;
  26151. private _bindPose;
  26152. private _baseMatrix;
  26153. private _absoluteTransform;
  26154. private _invertedAbsoluteTransform;
  26155. private _parent;
  26156. private _scalingDeterminant;
  26157. private _worldTransform;
  26158. private _localScaling;
  26159. private _localRotation;
  26160. private _localPosition;
  26161. private _needToDecompose;
  26162. private _needToCompose;
  26163. /** @hidden */
  26164. _linkedTransformNode: Nullable<TransformNode>;
  26165. /** @hidden */
  26166. _waitingTransformNodeId: Nullable<string>;
  26167. /** @hidden */
  26168. get _matrix(): Matrix;
  26169. /** @hidden */
  26170. set _matrix(value: Matrix);
  26171. /**
  26172. * Create a new bone
  26173. * @param name defines the bone name
  26174. * @param skeleton defines the parent skeleton
  26175. * @param parentBone defines the parent (can be null if the bone is the root)
  26176. * @param localMatrix defines the local matrix
  26177. * @param restPose defines the rest pose matrix
  26178. * @param baseMatrix defines the base matrix
  26179. * @param index defines index of the bone in the hiearchy
  26180. */
  26181. constructor(
  26182. /**
  26183. * defines the bone name
  26184. */
  26185. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26186. /**
  26187. * Gets the current object class name.
  26188. * @return the class name
  26189. */
  26190. getClassName(): string;
  26191. /**
  26192. * Gets the parent skeleton
  26193. * @returns a skeleton
  26194. */
  26195. getSkeleton(): Skeleton;
  26196. /**
  26197. * Gets parent bone
  26198. * @returns a bone or null if the bone is the root of the bone hierarchy
  26199. */
  26200. getParent(): Nullable<Bone>;
  26201. /**
  26202. * Returns an array containing the root bones
  26203. * @returns an array containing the root bones
  26204. */
  26205. getChildren(): Array<Bone>;
  26206. /**
  26207. * Gets the node index in matrix array generated for rendering
  26208. * @returns the node index
  26209. */
  26210. getIndex(): number;
  26211. /**
  26212. * Sets the parent bone
  26213. * @param parent defines the parent (can be null if the bone is the root)
  26214. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26215. */
  26216. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26217. /**
  26218. * Gets the local matrix
  26219. * @returns a matrix
  26220. */
  26221. getLocalMatrix(): Matrix;
  26222. /**
  26223. * Gets the base matrix (initial matrix which remains unchanged)
  26224. * @returns a matrix
  26225. */
  26226. getBaseMatrix(): Matrix;
  26227. /**
  26228. * Gets the rest pose matrix
  26229. * @returns a matrix
  26230. */
  26231. getRestPose(): Matrix;
  26232. /**
  26233. * Sets the rest pose matrix
  26234. * @param matrix the local-space rest pose to set for this bone
  26235. */
  26236. setRestPose(matrix: Matrix): void;
  26237. /**
  26238. * Gets the bind pose matrix
  26239. * @returns the bind pose matrix
  26240. */
  26241. getBindPose(): Matrix;
  26242. /**
  26243. * Sets the bind pose matrix
  26244. * @param matrix the local-space bind pose to set for this bone
  26245. */
  26246. setBindPose(matrix: Matrix): void;
  26247. /**
  26248. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26249. */
  26250. getWorldMatrix(): Matrix;
  26251. /**
  26252. * Sets the local matrix to rest pose matrix
  26253. */
  26254. returnToRest(): void;
  26255. /**
  26256. * Gets the inverse of the absolute transform matrix.
  26257. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26258. * @returns a matrix
  26259. */
  26260. getInvertedAbsoluteTransform(): Matrix;
  26261. /**
  26262. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26263. * @returns a matrix
  26264. */
  26265. getAbsoluteTransform(): Matrix;
  26266. /**
  26267. * Links with the given transform node.
  26268. * The local matrix of this bone is copied from the transform node every frame.
  26269. * @param transformNode defines the transform node to link to
  26270. */
  26271. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26272. /**
  26273. * Gets the node used to drive the bone's transformation
  26274. * @returns a transform node or null
  26275. */
  26276. getTransformNode(): Nullable<TransformNode>;
  26277. /** Gets or sets current position (in local space) */
  26278. get position(): Vector3;
  26279. set position(newPosition: Vector3);
  26280. /** Gets or sets current rotation (in local space) */
  26281. get rotation(): Vector3;
  26282. set rotation(newRotation: Vector3);
  26283. /** Gets or sets current rotation quaternion (in local space) */
  26284. get rotationQuaternion(): Quaternion;
  26285. set rotationQuaternion(newRotation: Quaternion);
  26286. /** Gets or sets current scaling (in local space) */
  26287. get scaling(): Vector3;
  26288. set scaling(newScaling: Vector3);
  26289. /**
  26290. * Gets the animation properties override
  26291. */
  26292. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26293. private _decompose;
  26294. private _compose;
  26295. /**
  26296. * Update the base and local matrices
  26297. * @param matrix defines the new base or local matrix
  26298. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26299. * @param updateLocalMatrix defines if the local matrix should be updated
  26300. */
  26301. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26302. /** @hidden */
  26303. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26304. /**
  26305. * Flag the bone as dirty (Forcing it to update everything)
  26306. */
  26307. markAsDirty(): void;
  26308. /** @hidden */
  26309. _markAsDirtyAndCompose(): void;
  26310. private _markAsDirtyAndDecompose;
  26311. /**
  26312. * Translate the bone in local or world space
  26313. * @param vec The amount to translate the bone
  26314. * @param space The space that the translation is in
  26315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26316. */
  26317. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26318. /**
  26319. * Set the postion of the bone in local or world space
  26320. * @param position The position to set the bone
  26321. * @param space The space that the position is in
  26322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26323. */
  26324. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26325. /**
  26326. * Set the absolute position of the bone (world space)
  26327. * @param position The position to set the bone
  26328. * @param mesh The mesh that this bone is attached to
  26329. */
  26330. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26331. /**
  26332. * Scale the bone on the x, y and z axes (in local space)
  26333. * @param x The amount to scale the bone on the x axis
  26334. * @param y The amount to scale the bone on the y axis
  26335. * @param z The amount to scale the bone on the z axis
  26336. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26337. */
  26338. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26339. /**
  26340. * Set the bone scaling in local space
  26341. * @param scale defines the scaling vector
  26342. */
  26343. setScale(scale: Vector3): void;
  26344. /**
  26345. * Gets the current scaling in local space
  26346. * @returns the current scaling vector
  26347. */
  26348. getScale(): Vector3;
  26349. /**
  26350. * Gets the current scaling in local space and stores it in a target vector
  26351. * @param result defines the target vector
  26352. */
  26353. getScaleToRef(result: Vector3): void;
  26354. /**
  26355. * Set the yaw, pitch, and roll of the bone in local or world space
  26356. * @param yaw The rotation of the bone on the y axis
  26357. * @param pitch The rotation of the bone on the x axis
  26358. * @param roll The rotation of the bone on the z axis
  26359. * @param space The space that the axes of rotation are in
  26360. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26361. */
  26362. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26363. /**
  26364. * Add a rotation to the bone on an axis in local or world space
  26365. * @param axis The axis to rotate the bone on
  26366. * @param amount The amount to rotate the bone
  26367. * @param space The space that the axis is in
  26368. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26369. */
  26370. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26371. /**
  26372. * Set the rotation of the bone to a particular axis angle in local or world space
  26373. * @param axis The axis to rotate the bone on
  26374. * @param angle The angle that the bone should be rotated to
  26375. * @param space The space that the axis is in
  26376. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26377. */
  26378. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26379. /**
  26380. * Set the euler rotation of the bone in local or world space
  26381. * @param rotation The euler rotation that the bone should be set to
  26382. * @param space The space that the rotation is in
  26383. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26384. */
  26385. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26386. /**
  26387. * Set the quaternion rotation of the bone in local or world space
  26388. * @param quat The quaternion rotation that the bone should be set to
  26389. * @param space The space that the rotation is in
  26390. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26391. */
  26392. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26393. /**
  26394. * Set the rotation matrix of the bone in local or world space
  26395. * @param rotMat The rotation matrix that the bone should be set to
  26396. * @param space The space that the rotation is in
  26397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26398. */
  26399. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26400. private _rotateWithMatrix;
  26401. private _getNegativeRotationToRef;
  26402. /**
  26403. * Get the position of the bone in local or world space
  26404. * @param space The space that the returned position is in
  26405. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26406. * @returns The position of the bone
  26407. */
  26408. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26409. /**
  26410. * Copy the position of the bone to a vector3 in local or world space
  26411. * @param space The space that the returned position is in
  26412. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26413. * @param result The vector3 to copy the position to
  26414. */
  26415. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26416. /**
  26417. * Get the absolute position of the bone (world space)
  26418. * @param mesh The mesh that this bone is attached to
  26419. * @returns The absolute position of the bone
  26420. */
  26421. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26422. /**
  26423. * Copy the absolute position of the bone (world space) to the result param
  26424. * @param mesh The mesh that this bone is attached to
  26425. * @param result The vector3 to copy the absolute position to
  26426. */
  26427. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26428. /**
  26429. * Compute the absolute transforms of this bone and its children
  26430. */
  26431. computeAbsoluteTransforms(): void;
  26432. /**
  26433. * Get the world direction from an axis that is in the local space of the bone
  26434. * @param localAxis The local direction that is used to compute the world direction
  26435. * @param mesh The mesh that this bone is attached to
  26436. * @returns The world direction
  26437. */
  26438. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26439. /**
  26440. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26441. * @param localAxis The local direction that is used to compute the world direction
  26442. * @param mesh The mesh that this bone is attached to
  26443. * @param result The vector3 that the world direction will be copied to
  26444. */
  26445. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26446. /**
  26447. * Get the euler rotation of the bone in local or world space
  26448. * @param space The space that the rotation should be in
  26449. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26450. * @returns The euler rotation
  26451. */
  26452. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26453. /**
  26454. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26455. * @param space The space that the rotation should be in
  26456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26457. * @param result The vector3 that the rotation should be copied to
  26458. */
  26459. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26460. /**
  26461. * Get the quaternion rotation of the bone in either local or world space
  26462. * @param space The space that the rotation should be in
  26463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26464. * @returns The quaternion rotation
  26465. */
  26466. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26467. /**
  26468. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26469. * @param space The space that the rotation should be in
  26470. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26471. * @param result The quaternion that the rotation should be copied to
  26472. */
  26473. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26474. /**
  26475. * Get the rotation matrix of the bone in local or world space
  26476. * @param space The space that the rotation should be in
  26477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26478. * @returns The rotation matrix
  26479. */
  26480. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26481. /**
  26482. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26483. * @param space The space that the rotation should be in
  26484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26485. * @param result The quaternion that the rotation should be copied to
  26486. */
  26487. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26488. /**
  26489. * Get the world position of a point that is in the local space of the bone
  26490. * @param position The local position
  26491. * @param mesh The mesh that this bone is attached to
  26492. * @returns The world position
  26493. */
  26494. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26495. /**
  26496. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26497. * @param position The local position
  26498. * @param mesh The mesh that this bone is attached to
  26499. * @param result The vector3 that the world position should be copied to
  26500. */
  26501. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26502. /**
  26503. * Get the local position of a point that is in world space
  26504. * @param position The world position
  26505. * @param mesh The mesh that this bone is attached to
  26506. * @returns The local position
  26507. */
  26508. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26509. /**
  26510. * Get the local position of a point that is in world space and copy it to the result param
  26511. * @param position The world position
  26512. * @param mesh The mesh that this bone is attached to
  26513. * @param result The vector3 that the local position should be copied to
  26514. */
  26515. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26516. /**
  26517. * Set the current local matrix as the restPose for this bone.
  26518. */
  26519. setCurrentPoseAsRest(): void;
  26520. }
  26521. }
  26522. declare module BABYLON {
  26523. /**
  26524. * 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.
  26525. * @see https://doc.babylonjs.com/how_to/transformnode
  26526. */
  26527. export class TransformNode extends Node {
  26528. /**
  26529. * Object will not rotate to face the camera
  26530. */
  26531. static BILLBOARDMODE_NONE: number;
  26532. /**
  26533. * Object will rotate to face the camera but only on the x axis
  26534. */
  26535. static BILLBOARDMODE_X: number;
  26536. /**
  26537. * Object will rotate to face the camera but only on the y axis
  26538. */
  26539. static BILLBOARDMODE_Y: number;
  26540. /**
  26541. * Object will rotate to face the camera but only on the z axis
  26542. */
  26543. static BILLBOARDMODE_Z: number;
  26544. /**
  26545. * Object will rotate to face the camera
  26546. */
  26547. static BILLBOARDMODE_ALL: number;
  26548. /**
  26549. * Object will rotate to face the camera's position instead of orientation
  26550. */
  26551. static BILLBOARDMODE_USE_POSITION: number;
  26552. private static _TmpRotation;
  26553. private static _TmpScaling;
  26554. private static _TmpTranslation;
  26555. private _forward;
  26556. private _forwardInverted;
  26557. private _up;
  26558. private _right;
  26559. private _rightInverted;
  26560. private _position;
  26561. private _rotation;
  26562. private _rotationQuaternion;
  26563. protected _scaling: Vector3;
  26564. protected _isDirty: boolean;
  26565. private _transformToBoneReferal;
  26566. private _isAbsoluteSynced;
  26567. private _billboardMode;
  26568. /**
  26569. * Gets or sets the billboard mode. Default is 0.
  26570. *
  26571. * | Value | Type | Description |
  26572. * | --- | --- | --- |
  26573. * | 0 | BILLBOARDMODE_NONE | |
  26574. * | 1 | BILLBOARDMODE_X | |
  26575. * | 2 | BILLBOARDMODE_Y | |
  26576. * | 4 | BILLBOARDMODE_Z | |
  26577. * | 7 | BILLBOARDMODE_ALL | |
  26578. *
  26579. */
  26580. get billboardMode(): number;
  26581. set billboardMode(value: number);
  26582. private _preserveParentRotationForBillboard;
  26583. /**
  26584. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26585. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26586. */
  26587. get preserveParentRotationForBillboard(): boolean;
  26588. set preserveParentRotationForBillboard(value: boolean);
  26589. /**
  26590. * 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
  26591. */
  26592. scalingDeterminant: number;
  26593. private _infiniteDistance;
  26594. /**
  26595. * Gets or sets the distance of the object to max, often used by skybox
  26596. */
  26597. get infiniteDistance(): boolean;
  26598. set infiniteDistance(value: boolean);
  26599. /**
  26600. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26601. * By default the system will update normals to compensate
  26602. */
  26603. ignoreNonUniformScaling: boolean;
  26604. /**
  26605. * 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
  26606. */
  26607. reIntegrateRotationIntoRotationQuaternion: boolean;
  26608. /** @hidden */
  26609. _poseMatrix: Nullable<Matrix>;
  26610. /** @hidden */
  26611. _localMatrix: Matrix;
  26612. private _usePivotMatrix;
  26613. private _absolutePosition;
  26614. private _absoluteScaling;
  26615. private _absoluteRotationQuaternion;
  26616. private _pivotMatrix;
  26617. private _pivotMatrixInverse;
  26618. /** @hidden */
  26619. _postMultiplyPivotMatrix: boolean;
  26620. protected _isWorldMatrixFrozen: boolean;
  26621. /** @hidden */
  26622. _indexInSceneTransformNodesArray: number;
  26623. /**
  26624. * An event triggered after the world matrix is updated
  26625. */
  26626. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26627. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26628. /**
  26629. * Gets a string identifying the name of the class
  26630. * @returns "TransformNode" string
  26631. */
  26632. getClassName(): string;
  26633. /**
  26634. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26635. */
  26636. get position(): Vector3;
  26637. set position(newPosition: Vector3);
  26638. /**
  26639. * 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)).
  26640. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26641. */
  26642. get rotation(): Vector3;
  26643. set rotation(newRotation: Vector3);
  26644. /**
  26645. * 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)).
  26646. */
  26647. get scaling(): Vector3;
  26648. set scaling(newScaling: Vector3);
  26649. /**
  26650. * 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).
  26651. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26652. */
  26653. get rotationQuaternion(): Nullable<Quaternion>;
  26654. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26655. /**
  26656. * The forward direction of that transform in world space.
  26657. */
  26658. get forward(): Vector3;
  26659. /**
  26660. * The up direction of that transform in world space.
  26661. */
  26662. get up(): Vector3;
  26663. /**
  26664. * The right direction of that transform in world space.
  26665. */
  26666. get right(): Vector3;
  26667. /**
  26668. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26669. * @param matrix the matrix to copy the pose from
  26670. * @returns this TransformNode.
  26671. */
  26672. updatePoseMatrix(matrix: Matrix): TransformNode;
  26673. /**
  26674. * Returns the mesh Pose matrix.
  26675. * @returns the pose matrix
  26676. */
  26677. getPoseMatrix(): Matrix;
  26678. /** @hidden */
  26679. _isSynchronized(): boolean;
  26680. /** @hidden */
  26681. _initCache(): void;
  26682. /**
  26683. * Flag the transform node as dirty (Forcing it to update everything)
  26684. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26685. * @returns this transform node
  26686. */
  26687. markAsDirty(property: string): TransformNode;
  26688. /**
  26689. * Returns the current mesh absolute position.
  26690. * Returns a Vector3.
  26691. */
  26692. get absolutePosition(): Vector3;
  26693. /**
  26694. * Returns the current mesh absolute scaling.
  26695. * Returns a Vector3.
  26696. */
  26697. get absoluteScaling(): Vector3;
  26698. /**
  26699. * Returns the current mesh absolute rotation.
  26700. * Returns a Quaternion.
  26701. */
  26702. get absoluteRotationQuaternion(): Quaternion;
  26703. /**
  26704. * Sets a new matrix to apply before all other transformation
  26705. * @param matrix defines the transform matrix
  26706. * @returns the current TransformNode
  26707. */
  26708. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26709. /**
  26710. * Sets a new pivot matrix to the current node
  26711. * @param matrix defines the new pivot matrix to use
  26712. * @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
  26713. * @returns the current TransformNode
  26714. */
  26715. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26716. /**
  26717. * Returns the mesh pivot matrix.
  26718. * Default : Identity.
  26719. * @returns the matrix
  26720. */
  26721. getPivotMatrix(): Matrix;
  26722. /**
  26723. * Instantiate (when possible) or clone that node with its hierarchy
  26724. * @param newParent defines the new parent to use for the instance (or clone)
  26725. * @param options defines options to configure how copy is done
  26726. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26727. * @returns an instance (or a clone) of the current node with its hiearchy
  26728. */
  26729. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26730. doNotInstantiate: boolean;
  26731. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26732. /**
  26733. * Prevents the World matrix to be computed any longer
  26734. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26735. * @returns the TransformNode.
  26736. */
  26737. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26738. /**
  26739. * Allows back the World matrix computation.
  26740. * @returns the TransformNode.
  26741. */
  26742. unfreezeWorldMatrix(): this;
  26743. /**
  26744. * True if the World matrix has been frozen.
  26745. */
  26746. get isWorldMatrixFrozen(): boolean;
  26747. /**
  26748. * Retuns the mesh absolute position in the World.
  26749. * @returns a Vector3.
  26750. */
  26751. getAbsolutePosition(): Vector3;
  26752. /**
  26753. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26754. * @param absolutePosition the absolute position to set
  26755. * @returns the TransformNode.
  26756. */
  26757. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26758. /**
  26759. * Sets the mesh position in its local space.
  26760. * @param vector3 the position to set in localspace
  26761. * @returns the TransformNode.
  26762. */
  26763. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26764. /**
  26765. * Returns the mesh position in the local space from the current World matrix values.
  26766. * @returns a new Vector3.
  26767. */
  26768. getPositionExpressedInLocalSpace(): Vector3;
  26769. /**
  26770. * Translates the mesh along the passed Vector3 in its local space.
  26771. * @param vector3 the distance to translate in localspace
  26772. * @returns the TransformNode.
  26773. */
  26774. locallyTranslate(vector3: Vector3): TransformNode;
  26775. private static _lookAtVectorCache;
  26776. /**
  26777. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26778. * @param targetPoint the position (must be in same space as current mesh) to look at
  26779. * @param yawCor optional yaw (y-axis) correction in radians
  26780. * @param pitchCor optional pitch (x-axis) correction in radians
  26781. * @param rollCor optional roll (z-axis) correction in radians
  26782. * @param space the choosen space of the target
  26783. * @returns the TransformNode.
  26784. */
  26785. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26786. /**
  26787. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26788. * This Vector3 is expressed in the World space.
  26789. * @param localAxis axis to rotate
  26790. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26791. */
  26792. getDirection(localAxis: Vector3): Vector3;
  26793. /**
  26794. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26795. * localAxis is expressed in the mesh local space.
  26796. * result is computed in the Wordl space from the mesh World matrix.
  26797. * @param localAxis axis to rotate
  26798. * @param result the resulting transformnode
  26799. * @returns this TransformNode.
  26800. */
  26801. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26802. /**
  26803. * Sets this transform node rotation to the given local axis.
  26804. * @param localAxis the axis in local space
  26805. * @param yawCor optional yaw (y-axis) correction in radians
  26806. * @param pitchCor optional pitch (x-axis) correction in radians
  26807. * @param rollCor optional roll (z-axis) correction in radians
  26808. * @returns this TransformNode
  26809. */
  26810. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26811. /**
  26812. * Sets a new pivot point to the current node
  26813. * @param point defines the new pivot point to use
  26814. * @param space defines if the point is in world or local space (local by default)
  26815. * @returns the current TransformNode
  26816. */
  26817. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26818. /**
  26819. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26820. * @returns the pivot point
  26821. */
  26822. getPivotPoint(): Vector3;
  26823. /**
  26824. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26825. * @param result the vector3 to store the result
  26826. * @returns this TransformNode.
  26827. */
  26828. getPivotPointToRef(result: Vector3): TransformNode;
  26829. /**
  26830. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26831. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26832. */
  26833. getAbsolutePivotPoint(): Vector3;
  26834. /**
  26835. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26836. * @param result vector3 to store the result
  26837. * @returns this TransformNode.
  26838. */
  26839. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26840. /**
  26841. * Defines the passed node as the parent of the current node.
  26842. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26843. * @see https://doc.babylonjs.com/how_to/parenting
  26844. * @param node the node ot set as the parent
  26845. * @returns this TransformNode.
  26846. */
  26847. setParent(node: Nullable<Node>): TransformNode;
  26848. private _nonUniformScaling;
  26849. /**
  26850. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26851. */
  26852. get nonUniformScaling(): boolean;
  26853. /** @hidden */
  26854. _updateNonUniformScalingState(value: boolean): boolean;
  26855. /**
  26856. * Attach the current TransformNode to another TransformNode associated with a bone
  26857. * @param bone Bone affecting the TransformNode
  26858. * @param affectedTransformNode TransformNode associated with the bone
  26859. * @returns this object
  26860. */
  26861. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26862. /**
  26863. * Detach the transform node if its associated with a bone
  26864. * @returns this object
  26865. */
  26866. detachFromBone(): TransformNode;
  26867. private static _rotationAxisCache;
  26868. /**
  26869. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26870. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26871. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26872. * The passed axis is also normalized.
  26873. * @param axis the axis to rotate around
  26874. * @param amount the amount to rotate in radians
  26875. * @param space Space to rotate in (Default: local)
  26876. * @returns the TransformNode.
  26877. */
  26878. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26879. /**
  26880. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26881. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26882. * The passed axis is also normalized. .
  26883. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26884. * @param point the point to rotate around
  26885. * @param axis the axis to rotate around
  26886. * @param amount the amount to rotate in radians
  26887. * @returns the TransformNode
  26888. */
  26889. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26890. /**
  26891. * Translates the mesh along the axis vector for the passed distance in the given space.
  26892. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26893. * @param axis the axis to translate in
  26894. * @param distance the distance to translate
  26895. * @param space Space to rotate in (Default: local)
  26896. * @returns the TransformNode.
  26897. */
  26898. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26899. /**
  26900. * Adds a rotation step to the mesh current rotation.
  26901. * x, y, z are Euler angles expressed in radians.
  26902. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26903. * This means this rotation is made in the mesh local space only.
  26904. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26905. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26906. * ```javascript
  26907. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26908. * ```
  26909. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26910. * 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.
  26911. * @param x Rotation to add
  26912. * @param y Rotation to add
  26913. * @param z Rotation to add
  26914. * @returns the TransformNode.
  26915. */
  26916. addRotation(x: number, y: number, z: number): TransformNode;
  26917. /**
  26918. * @hidden
  26919. */
  26920. protected _getEffectiveParent(): Nullable<Node>;
  26921. /**
  26922. * Computes the world matrix of the node
  26923. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26924. * @returns the world matrix
  26925. */
  26926. computeWorldMatrix(force?: boolean): Matrix;
  26927. /**
  26928. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26929. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26930. */
  26931. resetLocalMatrix(independentOfChildren?: boolean): void;
  26932. protected _afterComputeWorldMatrix(): void;
  26933. /**
  26934. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26935. * @param func callback function to add
  26936. *
  26937. * @returns the TransformNode.
  26938. */
  26939. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26940. /**
  26941. * Removes a registered callback function.
  26942. * @param func callback function to remove
  26943. * @returns the TransformNode.
  26944. */
  26945. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26946. /**
  26947. * Gets the position of the current mesh in camera space
  26948. * @param camera defines the camera to use
  26949. * @returns a position
  26950. */
  26951. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26952. /**
  26953. * Returns the distance from the mesh to the active camera
  26954. * @param camera defines the camera to use
  26955. * @returns the distance
  26956. */
  26957. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26958. /**
  26959. * Clone the current transform node
  26960. * @param name Name of the new clone
  26961. * @param newParent New parent for the clone
  26962. * @param doNotCloneChildren Do not clone children hierarchy
  26963. * @returns the new transform node
  26964. */
  26965. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26966. /**
  26967. * Serializes the objects information.
  26968. * @param currentSerializationObject defines the object to serialize in
  26969. * @returns the serialized object
  26970. */
  26971. serialize(currentSerializationObject?: any): any;
  26972. /**
  26973. * Returns a new TransformNode object parsed from the source provided.
  26974. * @param parsedTransformNode is the source.
  26975. * @param scene the scne the object belongs to
  26976. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26977. * @returns a new TransformNode object parsed from the source provided.
  26978. */
  26979. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26980. /**
  26981. * Get all child-transformNodes of this node
  26982. * @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
  26983. * @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
  26984. * @returns an array of TransformNode
  26985. */
  26986. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  26987. /**
  26988. * Releases resources associated with this transform node.
  26989. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26990. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26991. */
  26992. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26993. /**
  26994. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26995. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26996. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26997. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26998. * @returns the current mesh
  26999. */
  27000. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27001. private _syncAbsoluteScalingAndRotation;
  27002. }
  27003. }
  27004. declare module BABYLON {
  27005. /**
  27006. * Defines the types of pose enabled controllers that are supported
  27007. */
  27008. export enum PoseEnabledControllerType {
  27009. /**
  27010. * HTC Vive
  27011. */
  27012. VIVE = 0,
  27013. /**
  27014. * Oculus Rift
  27015. */
  27016. OCULUS = 1,
  27017. /**
  27018. * Windows mixed reality
  27019. */
  27020. WINDOWS = 2,
  27021. /**
  27022. * Samsung gear VR
  27023. */
  27024. GEAR_VR = 3,
  27025. /**
  27026. * Google Daydream
  27027. */
  27028. DAYDREAM = 4,
  27029. /**
  27030. * Generic
  27031. */
  27032. GENERIC = 5
  27033. }
  27034. /**
  27035. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27036. */
  27037. export interface MutableGamepadButton {
  27038. /**
  27039. * Value of the button/trigger
  27040. */
  27041. value: number;
  27042. /**
  27043. * If the button/trigger is currently touched
  27044. */
  27045. touched: boolean;
  27046. /**
  27047. * If the button/trigger is currently pressed
  27048. */
  27049. pressed: boolean;
  27050. }
  27051. /**
  27052. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27053. * @hidden
  27054. */
  27055. export interface ExtendedGamepadButton extends GamepadButton {
  27056. /**
  27057. * If the button/trigger is currently pressed
  27058. */
  27059. readonly pressed: boolean;
  27060. /**
  27061. * If the button/trigger is currently touched
  27062. */
  27063. readonly touched: boolean;
  27064. /**
  27065. * Value of the button/trigger
  27066. */
  27067. readonly value: number;
  27068. }
  27069. /** @hidden */
  27070. export interface _GamePadFactory {
  27071. /**
  27072. * Returns whether or not the current gamepad can be created for this type of controller.
  27073. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27074. * @returns true if it can be created, otherwise false
  27075. */
  27076. canCreate(gamepadInfo: any): boolean;
  27077. /**
  27078. * Creates a new instance of the Gamepad.
  27079. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27080. * @returns the new gamepad instance
  27081. */
  27082. create(gamepadInfo: any): Gamepad;
  27083. }
  27084. /**
  27085. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27086. */
  27087. export class PoseEnabledControllerHelper {
  27088. /** @hidden */
  27089. static _ControllerFactories: _GamePadFactory[];
  27090. /** @hidden */
  27091. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27092. /**
  27093. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27094. * @param vrGamepad the gamepad to initialized
  27095. * @returns a vr controller of the type the gamepad identified as
  27096. */
  27097. static InitiateController(vrGamepad: any): Gamepad;
  27098. }
  27099. /**
  27100. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27101. */
  27102. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27103. /**
  27104. * If the controller is used in a webXR session
  27105. */
  27106. isXR: boolean;
  27107. private _deviceRoomPosition;
  27108. private _deviceRoomRotationQuaternion;
  27109. /**
  27110. * The device position in babylon space
  27111. */
  27112. devicePosition: Vector3;
  27113. /**
  27114. * The device rotation in babylon space
  27115. */
  27116. deviceRotationQuaternion: Quaternion;
  27117. /**
  27118. * The scale factor of the device in babylon space
  27119. */
  27120. deviceScaleFactor: number;
  27121. /**
  27122. * (Likely devicePosition should be used instead) The device position in its room space
  27123. */
  27124. position: Vector3;
  27125. /**
  27126. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27127. */
  27128. rotationQuaternion: Quaternion;
  27129. /**
  27130. * The type of controller (Eg. Windows mixed reality)
  27131. */
  27132. controllerType: PoseEnabledControllerType;
  27133. protected _calculatedPosition: Vector3;
  27134. private _calculatedRotation;
  27135. /**
  27136. * The raw pose from the device
  27137. */
  27138. rawPose: DevicePose;
  27139. private _trackPosition;
  27140. private _maxRotationDistFromHeadset;
  27141. private _draggedRoomRotation;
  27142. /**
  27143. * @hidden
  27144. */
  27145. _disableTrackPosition(fixedPosition: Vector3): void;
  27146. /**
  27147. * Internal, the mesh attached to the controller
  27148. * @hidden
  27149. */
  27150. _mesh: Nullable<AbstractMesh>;
  27151. private _poseControlledCamera;
  27152. private _leftHandSystemQuaternion;
  27153. /**
  27154. * Internal, matrix used to convert room space to babylon space
  27155. * @hidden
  27156. */
  27157. _deviceToWorld: Matrix;
  27158. /**
  27159. * Node to be used when casting a ray from the controller
  27160. * @hidden
  27161. */
  27162. _pointingPoseNode: Nullable<TransformNode>;
  27163. /**
  27164. * Name of the child mesh that can be used to cast a ray from the controller
  27165. */
  27166. static readonly POINTING_POSE: string;
  27167. /**
  27168. * Creates a new PoseEnabledController from a gamepad
  27169. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27170. */
  27171. constructor(browserGamepad: any);
  27172. private _workingMatrix;
  27173. /**
  27174. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27175. */
  27176. update(): void;
  27177. /**
  27178. * Updates only the pose device and mesh without doing any button event checking
  27179. */
  27180. protected _updatePoseAndMesh(): void;
  27181. /**
  27182. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27183. * @param poseData raw pose fromthe device
  27184. */
  27185. updateFromDevice(poseData: DevicePose): void;
  27186. /**
  27187. * @hidden
  27188. */
  27189. _meshAttachedObservable: Observable<AbstractMesh>;
  27190. /**
  27191. * Attaches a mesh to the controller
  27192. * @param mesh the mesh to be attached
  27193. */
  27194. attachToMesh(mesh: AbstractMesh): void;
  27195. /**
  27196. * Attaches the controllers mesh to a camera
  27197. * @param camera the camera the mesh should be attached to
  27198. */
  27199. attachToPoseControlledCamera(camera: TargetCamera): void;
  27200. /**
  27201. * Disposes of the controller
  27202. */
  27203. dispose(): void;
  27204. /**
  27205. * The mesh that is attached to the controller
  27206. */
  27207. get mesh(): Nullable<AbstractMesh>;
  27208. /**
  27209. * Gets the ray of the controller in the direction the controller is pointing
  27210. * @param length the length the resulting ray should be
  27211. * @returns a ray in the direction the controller is pointing
  27212. */
  27213. getForwardRay(length?: number): Ray;
  27214. }
  27215. }
  27216. declare module BABYLON {
  27217. /**
  27218. * Defines the WebVRController object that represents controllers tracked in 3D space
  27219. */
  27220. export abstract class WebVRController extends PoseEnabledController {
  27221. /**
  27222. * Internal, the default controller model for the controller
  27223. */
  27224. protected _defaultModel: Nullable<AbstractMesh>;
  27225. /**
  27226. * Fired when the trigger state has changed
  27227. */
  27228. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27229. /**
  27230. * Fired when the main button state has changed
  27231. */
  27232. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27233. /**
  27234. * Fired when the secondary button state has changed
  27235. */
  27236. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27237. /**
  27238. * Fired when the pad state has changed
  27239. */
  27240. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27241. /**
  27242. * Fired when controllers stick values have changed
  27243. */
  27244. onPadValuesChangedObservable: Observable<StickValues>;
  27245. /**
  27246. * Array of button availible on the controller
  27247. */
  27248. protected _buttons: Array<MutableGamepadButton>;
  27249. private _onButtonStateChange;
  27250. /**
  27251. * Fired when a controller button's state has changed
  27252. * @param callback the callback containing the button that was modified
  27253. */
  27254. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27255. /**
  27256. * X and Y axis corresponding to the controllers joystick
  27257. */
  27258. pad: StickValues;
  27259. /**
  27260. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27261. */
  27262. hand: string;
  27263. /**
  27264. * The default controller model for the controller
  27265. */
  27266. get defaultModel(): Nullable<AbstractMesh>;
  27267. /**
  27268. * Creates a new WebVRController from a gamepad
  27269. * @param vrGamepad the gamepad that the WebVRController should be created from
  27270. */
  27271. constructor(vrGamepad: any);
  27272. /**
  27273. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27274. */
  27275. update(): void;
  27276. /**
  27277. * Function to be called when a button is modified
  27278. */
  27279. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27280. /**
  27281. * Loads a mesh and attaches it to the controller
  27282. * @param scene the scene the mesh should be added to
  27283. * @param meshLoaded callback for when the mesh has been loaded
  27284. */
  27285. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27286. private _setButtonValue;
  27287. private _changes;
  27288. private _checkChanges;
  27289. /**
  27290. * Disposes of th webVRCOntroller
  27291. */
  27292. dispose(): void;
  27293. }
  27294. }
  27295. declare module BABYLON {
  27296. /**
  27297. * The HemisphericLight simulates the ambient environment light,
  27298. * so the passed direction is the light reflection direction, not the incoming direction.
  27299. */
  27300. export class HemisphericLight extends Light {
  27301. /**
  27302. * The groundColor is the light in the opposite direction to the one specified during creation.
  27303. * 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.
  27304. */
  27305. groundColor: Color3;
  27306. /**
  27307. * The light reflection direction, not the incoming direction.
  27308. */
  27309. direction: Vector3;
  27310. /**
  27311. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27312. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27313. * The HemisphericLight can't cast shadows.
  27314. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27315. * @param name The friendly name of the light
  27316. * @param direction The direction of the light reflection
  27317. * @param scene The scene the light belongs to
  27318. */
  27319. constructor(name: string, direction: Vector3, scene: Scene);
  27320. protected _buildUniformLayout(): void;
  27321. /**
  27322. * Returns the string "HemisphericLight".
  27323. * @return The class name
  27324. */
  27325. getClassName(): string;
  27326. /**
  27327. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27328. * Returns the updated direction.
  27329. * @param target The target the direction should point to
  27330. * @return The computed direction
  27331. */
  27332. setDirectionToTarget(target: Vector3): Vector3;
  27333. /**
  27334. * Returns the shadow generator associated to the light.
  27335. * @returns Always null for hemispheric lights because it does not support shadows.
  27336. */
  27337. getShadowGenerator(): Nullable<IShadowGenerator>;
  27338. /**
  27339. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27340. * @param effect The effect to update
  27341. * @param lightIndex The index of the light in the effect to update
  27342. * @returns The hemispheric light
  27343. */
  27344. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27345. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27346. /**
  27347. * Computes the world matrix of the node
  27348. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27349. * @param useWasUpdatedFlag defines a reserved property
  27350. * @returns the world matrix
  27351. */
  27352. computeWorldMatrix(): Matrix;
  27353. /**
  27354. * Returns the integer 3.
  27355. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27356. */
  27357. getTypeID(): number;
  27358. /**
  27359. * Prepares the list of defines specific to the light type.
  27360. * @param defines the list of defines
  27361. * @param lightIndex defines the index of the light for the effect
  27362. */
  27363. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27364. }
  27365. }
  27366. declare module BABYLON {
  27367. /** @hidden */
  27368. export var vrMultiviewToSingleviewPixelShader: {
  27369. name: string;
  27370. shader: string;
  27371. };
  27372. }
  27373. declare module BABYLON {
  27374. /**
  27375. * Renders to multiple views with a single draw call
  27376. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27377. */
  27378. export class MultiviewRenderTarget extends RenderTargetTexture {
  27379. /**
  27380. * Creates a multiview render target
  27381. * @param scene scene used with the render target
  27382. * @param size the size of the render target (used for each view)
  27383. */
  27384. constructor(scene: Scene, size?: number | {
  27385. width: number;
  27386. height: number;
  27387. } | {
  27388. ratio: number;
  27389. });
  27390. /**
  27391. * @hidden
  27392. * @param faceIndex the face index, if its a cube texture
  27393. */
  27394. _bindFrameBuffer(faceIndex?: number): void;
  27395. /**
  27396. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27397. * @returns the view count
  27398. */
  27399. getViewCount(): number;
  27400. }
  27401. }
  27402. declare module BABYLON {
  27403. interface Engine {
  27404. /**
  27405. * Creates a new multiview render target
  27406. * @param width defines the width of the texture
  27407. * @param height defines the height of the texture
  27408. * @returns the created multiview texture
  27409. */
  27410. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27411. /**
  27412. * Binds a multiview framebuffer to be drawn to
  27413. * @param multiviewTexture texture to bind
  27414. */
  27415. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27416. }
  27417. interface Camera {
  27418. /**
  27419. * @hidden
  27420. * 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)
  27421. */
  27422. _useMultiviewToSingleView: boolean;
  27423. /**
  27424. * @hidden
  27425. * 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)
  27426. */
  27427. _multiviewTexture: Nullable<RenderTargetTexture>;
  27428. /**
  27429. * @hidden
  27430. * ensures the multiview texture of the camera exists and has the specified width/height
  27431. * @param width height to set on the multiview texture
  27432. * @param height width to set on the multiview texture
  27433. */
  27434. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27435. }
  27436. interface Scene {
  27437. /** @hidden */
  27438. _transformMatrixR: Matrix;
  27439. /** @hidden */
  27440. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27441. /** @hidden */
  27442. _createMultiviewUbo(): void;
  27443. /** @hidden */
  27444. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27445. /** @hidden */
  27446. _renderMultiviewToSingleView(camera: Camera): void;
  27447. }
  27448. }
  27449. declare module BABYLON {
  27450. /**
  27451. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27452. * This will not be used for webXR as it supports displaying texture arrays directly
  27453. */
  27454. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27455. /**
  27456. * Gets a string identifying the name of the class
  27457. * @returns "VRMultiviewToSingleviewPostProcess" string
  27458. */
  27459. getClassName(): string;
  27460. /**
  27461. * Initializes a VRMultiviewToSingleview
  27462. * @param name name of the post process
  27463. * @param camera camera to be applied to
  27464. * @param scaleFactor scaling factor to the size of the output texture
  27465. */
  27466. constructor(name: string, camera: Camera, scaleFactor: number);
  27467. }
  27468. }
  27469. declare module BABYLON {
  27470. /**
  27471. * Interface used to define additional presentation attributes
  27472. */
  27473. export interface IVRPresentationAttributes {
  27474. /**
  27475. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27476. */
  27477. highRefreshRate: boolean;
  27478. /**
  27479. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27480. */
  27481. foveationLevel: number;
  27482. }
  27483. interface Engine {
  27484. /** @hidden */
  27485. _vrDisplay: any;
  27486. /** @hidden */
  27487. _vrSupported: boolean;
  27488. /** @hidden */
  27489. _oldSize: Size;
  27490. /** @hidden */
  27491. _oldHardwareScaleFactor: number;
  27492. /** @hidden */
  27493. _vrExclusivePointerMode: boolean;
  27494. /** @hidden */
  27495. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27496. /** @hidden */
  27497. _onVRDisplayPointerRestricted: () => void;
  27498. /** @hidden */
  27499. _onVRDisplayPointerUnrestricted: () => void;
  27500. /** @hidden */
  27501. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27502. /** @hidden */
  27503. _onVrDisplayDisconnect: Nullable<() => void>;
  27504. /** @hidden */
  27505. _onVrDisplayPresentChange: Nullable<() => void>;
  27506. /**
  27507. * Observable signaled when VR display mode changes
  27508. */
  27509. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27510. /**
  27511. * Observable signaled when VR request present is complete
  27512. */
  27513. onVRRequestPresentComplete: Observable<boolean>;
  27514. /**
  27515. * Observable signaled when VR request present starts
  27516. */
  27517. onVRRequestPresentStart: Observable<Engine>;
  27518. /**
  27519. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27520. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27521. */
  27522. isInVRExclusivePointerMode: boolean;
  27523. /**
  27524. * Gets a boolean indicating if a webVR device was detected
  27525. * @returns true if a webVR device was detected
  27526. */
  27527. isVRDevicePresent(): boolean;
  27528. /**
  27529. * Gets the current webVR device
  27530. * @returns the current webVR device (or null)
  27531. */
  27532. getVRDevice(): any;
  27533. /**
  27534. * Initializes a webVR display and starts listening to display change events
  27535. * The onVRDisplayChangedObservable will be notified upon these changes
  27536. * @returns A promise containing a VRDisplay and if vr is supported
  27537. */
  27538. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27539. /** @hidden */
  27540. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27541. /**
  27542. * Gets or sets the presentation attributes used to configure VR rendering
  27543. */
  27544. vrPresentationAttributes?: IVRPresentationAttributes;
  27545. /**
  27546. * Call this function to switch to webVR mode
  27547. * Will do nothing if webVR is not supported or if there is no webVR device
  27548. * @param options the webvr options provided to the camera. mainly used for multiview
  27549. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27550. */
  27551. enableVR(options: WebVROptions): void;
  27552. /** @hidden */
  27553. _onVRFullScreenTriggered(): void;
  27554. }
  27555. }
  27556. declare module BABYLON {
  27557. /**
  27558. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27559. * IMPORTANT!! The data is right-hand data.
  27560. * @export
  27561. * @interface DevicePose
  27562. */
  27563. export interface DevicePose {
  27564. /**
  27565. * The position of the device, values in array are [x,y,z].
  27566. */
  27567. readonly position: Nullable<Float32Array>;
  27568. /**
  27569. * The linearVelocity of the device, values in array are [x,y,z].
  27570. */
  27571. readonly linearVelocity: Nullable<Float32Array>;
  27572. /**
  27573. * The linearAcceleration of the device, values in array are [x,y,z].
  27574. */
  27575. readonly linearAcceleration: Nullable<Float32Array>;
  27576. /**
  27577. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27578. */
  27579. readonly orientation: Nullable<Float32Array>;
  27580. /**
  27581. * The angularVelocity of the device, values in array are [x,y,z].
  27582. */
  27583. readonly angularVelocity: Nullable<Float32Array>;
  27584. /**
  27585. * The angularAcceleration of the device, values in array are [x,y,z].
  27586. */
  27587. readonly angularAcceleration: Nullable<Float32Array>;
  27588. }
  27589. /**
  27590. * Interface representing a pose controlled object in Babylon.
  27591. * A pose controlled object has both regular pose values as well as pose values
  27592. * from an external device such as a VR head mounted display
  27593. */
  27594. export interface PoseControlled {
  27595. /**
  27596. * The position of the object in babylon space.
  27597. */
  27598. position: Vector3;
  27599. /**
  27600. * The rotation quaternion of the object in babylon space.
  27601. */
  27602. rotationQuaternion: Quaternion;
  27603. /**
  27604. * The position of the device in babylon space.
  27605. */
  27606. devicePosition?: Vector3;
  27607. /**
  27608. * The rotation quaternion of the device in babylon space.
  27609. */
  27610. deviceRotationQuaternion: Quaternion;
  27611. /**
  27612. * The raw pose coming from the device.
  27613. */
  27614. rawPose: Nullable<DevicePose>;
  27615. /**
  27616. * The scale of the device to be used when translating from device space to babylon space.
  27617. */
  27618. deviceScaleFactor: number;
  27619. /**
  27620. * Updates the poseControlled values based on the input device pose.
  27621. * @param poseData the pose data to update the object with
  27622. */
  27623. updateFromDevice(poseData: DevicePose): void;
  27624. }
  27625. /**
  27626. * Set of options to customize the webVRCamera
  27627. */
  27628. export interface WebVROptions {
  27629. /**
  27630. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27631. */
  27632. trackPosition?: boolean;
  27633. /**
  27634. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27635. */
  27636. positionScale?: number;
  27637. /**
  27638. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27639. */
  27640. displayName?: string;
  27641. /**
  27642. * Should the native controller meshes be initialized. (default: true)
  27643. */
  27644. controllerMeshes?: boolean;
  27645. /**
  27646. * Creating a default HemiLight only on controllers. (default: true)
  27647. */
  27648. defaultLightingOnControllers?: boolean;
  27649. /**
  27650. * If you don't want to use the default VR button of the helper. (default: false)
  27651. */
  27652. useCustomVRButton?: boolean;
  27653. /**
  27654. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27655. */
  27656. customVRButton?: HTMLButtonElement;
  27657. /**
  27658. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27659. */
  27660. rayLength?: number;
  27661. /**
  27662. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27663. */
  27664. defaultHeight?: number;
  27665. /**
  27666. * If multiview should be used if availible (default: false)
  27667. */
  27668. useMultiview?: boolean;
  27669. }
  27670. /**
  27671. * This represents a WebVR camera.
  27672. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27673. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27674. */
  27675. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27676. private webVROptions;
  27677. /**
  27678. * @hidden
  27679. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27680. */
  27681. _vrDevice: any;
  27682. /**
  27683. * The rawPose of the vrDevice.
  27684. */
  27685. rawPose: Nullable<DevicePose>;
  27686. private _onVREnabled;
  27687. private _specsVersion;
  27688. private _attached;
  27689. private _frameData;
  27690. protected _descendants: Array<Node>;
  27691. private _deviceRoomPosition;
  27692. /** @hidden */
  27693. _deviceRoomRotationQuaternion: Quaternion;
  27694. private _standingMatrix;
  27695. /**
  27696. * Represents device position in babylon space.
  27697. */
  27698. devicePosition: Vector3;
  27699. /**
  27700. * Represents device rotation in babylon space.
  27701. */
  27702. deviceRotationQuaternion: Quaternion;
  27703. /**
  27704. * The scale of the device to be used when translating from device space to babylon space.
  27705. */
  27706. deviceScaleFactor: number;
  27707. private _deviceToWorld;
  27708. private _worldToDevice;
  27709. /**
  27710. * References to the webVR controllers for the vrDevice.
  27711. */
  27712. controllers: Array<WebVRController>;
  27713. /**
  27714. * Emits an event when a controller is attached.
  27715. */
  27716. onControllersAttachedObservable: Observable<WebVRController[]>;
  27717. /**
  27718. * Emits an event when a controller's mesh has been loaded;
  27719. */
  27720. onControllerMeshLoadedObservable: Observable<WebVRController>;
  27721. /**
  27722. * Emits an event when the HMD's pose has been updated.
  27723. */
  27724. onPoseUpdatedFromDeviceObservable: Observable<any>;
  27725. private _poseSet;
  27726. /**
  27727. * If the rig cameras be used as parent instead of this camera.
  27728. */
  27729. rigParenting: boolean;
  27730. private _lightOnControllers;
  27731. private _defaultHeight?;
  27732. /**
  27733. * Instantiates a WebVRFreeCamera.
  27734. * @param name The name of the WebVRFreeCamera
  27735. * @param position The starting anchor position for the camera
  27736. * @param scene The scene the camera belongs to
  27737. * @param webVROptions a set of customizable options for the webVRCamera
  27738. */
  27739. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27740. /**
  27741. * Gets the device distance from the ground in meters.
  27742. * @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.
  27743. */
  27744. deviceDistanceToRoomGround(): number;
  27745. /**
  27746. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27747. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27748. */
  27749. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27750. /**
  27751. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27752. * @returns A promise with a boolean set to if the standing matrix is supported.
  27753. */
  27754. useStandingMatrixAsync(): Promise<boolean>;
  27755. /**
  27756. * Disposes the camera
  27757. */
  27758. dispose(): void;
  27759. /**
  27760. * Gets a vrController by name.
  27761. * @param name The name of the controller to retreive
  27762. * @returns the controller matching the name specified or null if not found
  27763. */
  27764. getControllerByName(name: string): Nullable<WebVRController>;
  27765. private _leftController;
  27766. /**
  27767. * The controller corresponding to the users left hand.
  27768. */
  27769. get leftController(): Nullable<WebVRController>;
  27770. private _rightController;
  27771. /**
  27772. * The controller corresponding to the users right hand.
  27773. */
  27774. get rightController(): Nullable<WebVRController>;
  27775. /**
  27776. * Casts a ray forward from the vrCamera's gaze.
  27777. * @param length Length of the ray (default: 100)
  27778. * @returns the ray corresponding to the gaze
  27779. */
  27780. getForwardRay(length?: number): Ray;
  27781. /**
  27782. * @hidden
  27783. * Updates the camera based on device's frame data
  27784. */
  27785. _checkInputs(): void;
  27786. /**
  27787. * Updates the poseControlled values based on the input device pose.
  27788. * @param poseData Pose coming from the device
  27789. */
  27790. updateFromDevice(poseData: DevicePose): void;
  27791. private _detachIfAttached;
  27792. /**
  27793. * WebVR's attach control will start broadcasting frames to the device.
  27794. * Note that in certain browsers (chrome for example) this function must be called
  27795. * within a user-interaction callback. Example:
  27796. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27797. *
  27798. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27799. */
  27800. attachControl(noPreventDefault?: boolean): void;
  27801. /**
  27802. * Detach the current controls from the specified dom element.
  27803. */
  27804. detachControl(): void;
  27805. /**
  27806. * @returns the name of this class
  27807. */
  27808. getClassName(): string;
  27809. /**
  27810. * Calls resetPose on the vrDisplay
  27811. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27812. */
  27813. resetToCurrentRotation(): void;
  27814. /**
  27815. * @hidden
  27816. * Updates the rig cameras (left and right eye)
  27817. */
  27818. _updateRigCameras(): void;
  27819. private _workingVector;
  27820. private _oneVector;
  27821. private _workingMatrix;
  27822. private updateCacheCalled;
  27823. private _correctPositionIfNotTrackPosition;
  27824. /**
  27825. * @hidden
  27826. * Updates the cached values of the camera
  27827. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27828. */
  27829. _updateCache(ignoreParentClass?: boolean): void;
  27830. /**
  27831. * @hidden
  27832. * Get current device position in babylon world
  27833. */
  27834. _computeDevicePosition(): void;
  27835. /**
  27836. * Updates the current device position and rotation in the babylon world
  27837. */
  27838. update(): void;
  27839. /**
  27840. * @hidden
  27841. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27842. * @returns an identity matrix
  27843. */
  27844. _getViewMatrix(): Matrix;
  27845. private _tmpMatrix;
  27846. /**
  27847. * This function is called by the two RIG cameras.
  27848. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27849. * @hidden
  27850. */
  27851. _getWebVRViewMatrix(): Matrix;
  27852. /** @hidden */
  27853. _getWebVRProjectionMatrix(): Matrix;
  27854. private _onGamepadConnectedObserver;
  27855. private _onGamepadDisconnectedObserver;
  27856. private _updateCacheWhenTrackingDisabledObserver;
  27857. /**
  27858. * Initializes the controllers and their meshes
  27859. */
  27860. initControllers(): void;
  27861. }
  27862. }
  27863. declare module BABYLON {
  27864. /**
  27865. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27866. *
  27867. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27868. *
  27869. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27870. */
  27871. export class MaterialHelper {
  27872. /**
  27873. * Bind the current view position to an effect.
  27874. * @param effect The effect to be bound
  27875. * @param scene The scene the eyes position is used from
  27876. * @param variableName name of the shader variable that will hold the eye position
  27877. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  27878. * @return the computed eye position
  27879. */
  27880. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  27881. /**
  27882. * Helps preparing the defines values about the UVs in used in the effect.
  27883. * UVs are shared as much as we can accross channels in the shaders.
  27884. * @param texture The texture we are preparing the UVs for
  27885. * @param defines The defines to update
  27886. * @param key The channel key "diffuse", "specular"... used in the shader
  27887. */
  27888. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27889. /**
  27890. * Binds a texture matrix value to its corrsponding uniform
  27891. * @param texture The texture to bind the matrix for
  27892. * @param uniformBuffer The uniform buffer receivin the data
  27893. * @param key The channel key "diffuse", "specular"... used in the shader
  27894. */
  27895. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27896. /**
  27897. * Gets the current status of the fog (should it be enabled?)
  27898. * @param mesh defines the mesh to evaluate for fog support
  27899. * @param scene defines the hosting scene
  27900. * @returns true if fog must be enabled
  27901. */
  27902. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27903. /**
  27904. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27905. * @param mesh defines the current mesh
  27906. * @param scene defines the current scene
  27907. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27908. * @param pointsCloud defines if point cloud rendering has to be turned on
  27909. * @param fogEnabled defines if fog has to be turned on
  27910. * @param alphaTest defines if alpha testing has to be turned on
  27911. * @param defines defines the current list of defines
  27912. */
  27913. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27914. /**
  27915. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27916. * @param scene defines the current scene
  27917. * @param engine defines the current engine
  27918. * @param defines specifies the list of active defines
  27919. * @param useInstances defines if instances have to be turned on
  27920. * @param useClipPlane defines if clip plane have to be turned on
  27921. * @param useInstances defines if instances have to be turned on
  27922. * @param useThinInstances defines if thin instances have to be turned on
  27923. */
  27924. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27925. /**
  27926. * Prepares the defines for bones
  27927. * @param mesh The mesh containing the geometry data we will draw
  27928. * @param defines The defines to update
  27929. */
  27930. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27931. /**
  27932. * Prepares the defines for morph targets
  27933. * @param mesh The mesh containing the geometry data we will draw
  27934. * @param defines The defines to update
  27935. */
  27936. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27937. /**
  27938. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27939. * @param mesh The mesh containing the geometry data we will draw
  27940. * @param defines The defines to update
  27941. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27942. * @param useBones Precise whether bones should be used or not (override mesh info)
  27943. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27944. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27945. * @returns false if defines are considered not dirty and have not been checked
  27946. */
  27947. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27948. /**
  27949. * Prepares the defines related to multiview
  27950. * @param scene The scene we are intending to draw
  27951. * @param defines The defines to update
  27952. */
  27953. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27954. /**
  27955. * Prepares the defines related to the prepass
  27956. * @param scene The scene we are intending to draw
  27957. * @param defines The defines to update
  27958. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27959. */
  27960. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27961. /**
  27962. * Prepares the defines related to the light information passed in parameter
  27963. * @param scene The scene we are intending to draw
  27964. * @param mesh The mesh the effect is compiling for
  27965. * @param light The light the effect is compiling for
  27966. * @param lightIndex The index of the light
  27967. * @param defines The defines to update
  27968. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27969. * @param state Defines the current state regarding what is needed (normals, etc...)
  27970. */
  27971. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27972. needNormals: boolean;
  27973. needRebuild: boolean;
  27974. shadowEnabled: boolean;
  27975. specularEnabled: boolean;
  27976. lightmapMode: boolean;
  27977. }): void;
  27978. /**
  27979. * Prepares the defines related to the light information passed in parameter
  27980. * @param scene The scene we are intending to draw
  27981. * @param mesh The mesh the effect is compiling for
  27982. * @param defines The defines to update
  27983. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27984. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  27985. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  27986. * @returns true if normals will be required for the rest of the effect
  27987. */
  27988. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  27989. /**
  27990. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  27991. * @param lightIndex defines the light index
  27992. * @param uniformsList The uniform list
  27993. * @param samplersList The sampler list
  27994. * @param projectedLightTexture defines if projected texture must be used
  27995. * @param uniformBuffersList defines an optional list of uniform buffers
  27996. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  27997. */
  27998. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  27999. /**
  28000. * Prepares the uniforms and samplers list to be used in the effect
  28001. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  28002. * @param samplersList The sampler list
  28003. * @param defines The defines helping in the list generation
  28004. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  28005. */
  28006. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28007. /**
  28008. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28009. * @param defines The defines to update while falling back
  28010. * @param fallbacks The authorized effect fallbacks
  28011. * @param maxSimultaneousLights The maximum number of lights allowed
  28012. * @param rank the current rank of the Effect
  28013. * @returns The newly affected rank
  28014. */
  28015. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28016. private static _TmpMorphInfluencers;
  28017. /**
  28018. * Prepares the list of attributes required for morph targets according to the effect defines.
  28019. * @param attribs The current list of supported attribs
  28020. * @param mesh The mesh to prepare the morph targets attributes for
  28021. * @param influencers The number of influencers
  28022. */
  28023. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28024. /**
  28025. * Prepares the list of attributes required for morph targets according to the effect defines.
  28026. * @param attribs The current list of supported attribs
  28027. * @param mesh The mesh to prepare the morph targets attributes for
  28028. * @param defines The current Defines of the effect
  28029. */
  28030. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28031. /**
  28032. * Prepares the list of attributes required for bones according to the effect defines.
  28033. * @param attribs The current list of supported attribs
  28034. * @param mesh The mesh to prepare the bones attributes for
  28035. * @param defines The current Defines of the effect
  28036. * @param fallbacks The current efffect fallback strategy
  28037. */
  28038. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28039. /**
  28040. * Check and prepare the list of attributes required for instances according to the effect defines.
  28041. * @param attribs The current list of supported attribs
  28042. * @param defines The current MaterialDefines of the effect
  28043. */
  28044. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28045. /**
  28046. * Add the list of attributes required for instances to the attribs array.
  28047. * @param attribs The current list of supported attribs
  28048. */
  28049. static PushAttributesForInstances(attribs: string[]): void;
  28050. /**
  28051. * Binds the light information to the effect.
  28052. * @param light The light containing the generator
  28053. * @param effect The effect we are binding the data to
  28054. * @param lightIndex The light index in the effect used to render
  28055. */
  28056. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28057. /**
  28058. * Binds the lights information from the scene to the effect for the given mesh.
  28059. * @param light Light to bind
  28060. * @param lightIndex Light index
  28061. * @param scene The scene where the light belongs to
  28062. * @param effect The effect we are binding the data to
  28063. * @param useSpecular Defines if specular is supported
  28064. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28065. */
  28066. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28067. /**
  28068. * Binds the lights information from the scene to the effect for the given mesh.
  28069. * @param scene The scene the lights belongs to
  28070. * @param mesh The mesh we are binding the information to render
  28071. * @param effect The effect we are binding the data to
  28072. * @param defines The generated defines for the effect
  28073. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28074. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28075. */
  28076. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28077. private static _tempFogColor;
  28078. /**
  28079. * Binds the fog information from the scene to the effect for the given mesh.
  28080. * @param scene The scene the lights belongs to
  28081. * @param mesh The mesh we are binding the information to render
  28082. * @param effect The effect we are binding the data to
  28083. * @param linearSpace Defines if the fog effect is applied in linear space
  28084. */
  28085. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28086. /**
  28087. * Binds the bones information from the mesh to the effect.
  28088. * @param mesh The mesh we are binding the information to render
  28089. * @param effect The effect we are binding the data to
  28090. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28091. */
  28092. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28093. private static _CopyBonesTransformationMatrices;
  28094. /**
  28095. * Binds the morph targets information from the mesh to the effect.
  28096. * @param abstractMesh The mesh we are binding the information to render
  28097. * @param effect The effect we are binding the data to
  28098. */
  28099. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28100. /**
  28101. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28102. * @param defines The generated defines used in the effect
  28103. * @param effect The effect we are binding the data to
  28104. * @param scene The scene we are willing to render with logarithmic scale for
  28105. */
  28106. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28107. /**
  28108. * Binds the clip plane information from the scene to the effect.
  28109. * @param scene The scene the clip plane information are extracted from
  28110. * @param effect The effect we are binding the data to
  28111. */
  28112. static BindClipPlane(effect: Effect, scene: Scene): void;
  28113. }
  28114. }
  28115. declare module BABYLON {
  28116. /** @hidden */
  28117. export var bayerDitherFunctions: {
  28118. name: string;
  28119. shader: string;
  28120. };
  28121. }
  28122. declare module BABYLON {
  28123. /** @hidden */
  28124. export var shadowMapFragmentDeclaration: {
  28125. name: string;
  28126. shader: string;
  28127. };
  28128. }
  28129. declare module BABYLON {
  28130. /** @hidden */
  28131. export var shadowMapFragment: {
  28132. name: string;
  28133. shader: string;
  28134. };
  28135. }
  28136. declare module BABYLON {
  28137. /** @hidden */
  28138. export var shadowMapPixelShader: {
  28139. name: string;
  28140. shader: string;
  28141. };
  28142. }
  28143. declare module BABYLON {
  28144. /** @hidden */
  28145. export var shadowMapVertexDeclaration: {
  28146. name: string;
  28147. shader: string;
  28148. };
  28149. }
  28150. declare module BABYLON {
  28151. /** @hidden */
  28152. export var shadowMapVertexNormalBias: {
  28153. name: string;
  28154. shader: string;
  28155. };
  28156. }
  28157. declare module BABYLON {
  28158. /** @hidden */
  28159. export var shadowMapVertexMetric: {
  28160. name: string;
  28161. shader: string;
  28162. };
  28163. }
  28164. declare module BABYLON {
  28165. /** @hidden */
  28166. export var shadowMapVertexShader: {
  28167. name: string;
  28168. shader: string;
  28169. };
  28170. }
  28171. declare module BABYLON {
  28172. /** @hidden */
  28173. export var depthBoxBlurPixelShader: {
  28174. name: string;
  28175. shader: string;
  28176. };
  28177. }
  28178. declare module BABYLON {
  28179. /** @hidden */
  28180. export var shadowMapFragmentSoftTransparentShadow: {
  28181. name: string;
  28182. shader: string;
  28183. };
  28184. }
  28185. declare module BABYLON {
  28186. /**
  28187. * Creates an instance based on a source mesh.
  28188. */
  28189. export class InstancedMesh extends AbstractMesh {
  28190. private _sourceMesh;
  28191. private _currentLOD;
  28192. /** @hidden */
  28193. _indexInSourceMeshInstanceArray: number;
  28194. constructor(name: string, source: Mesh);
  28195. /**
  28196. * Returns the string "InstancedMesh".
  28197. */
  28198. getClassName(): string;
  28199. /** Gets the list of lights affecting that mesh */
  28200. get lightSources(): Light[];
  28201. _resyncLightSources(): void;
  28202. _resyncLightSource(light: Light): void;
  28203. _removeLightSource(light: Light, dispose: boolean): void;
  28204. /**
  28205. * If the source mesh receives shadows
  28206. */
  28207. get receiveShadows(): boolean;
  28208. /**
  28209. * The material of the source mesh
  28210. */
  28211. get material(): Nullable<Material>;
  28212. /**
  28213. * Visibility of the source mesh
  28214. */
  28215. get visibility(): number;
  28216. /**
  28217. * Skeleton of the source mesh
  28218. */
  28219. get skeleton(): Nullable<Skeleton>;
  28220. /**
  28221. * Rendering ground id of the source mesh
  28222. */
  28223. get renderingGroupId(): number;
  28224. set renderingGroupId(value: number);
  28225. /**
  28226. * Returns the total number of vertices (integer).
  28227. */
  28228. getTotalVertices(): number;
  28229. /**
  28230. * Returns a positive integer : the total number of indices in this mesh geometry.
  28231. * @returns the numner of indices or zero if the mesh has no geometry.
  28232. */
  28233. getTotalIndices(): number;
  28234. /**
  28235. * The source mesh of the instance
  28236. */
  28237. get sourceMesh(): Mesh;
  28238. /**
  28239. * Creates a new InstancedMesh object from the mesh model.
  28240. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28241. * @param name defines the name of the new instance
  28242. * @returns a new InstancedMesh
  28243. */
  28244. createInstance(name: string): InstancedMesh;
  28245. /**
  28246. * Is this node ready to be used/rendered
  28247. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28248. * @return {boolean} is it ready
  28249. */
  28250. isReady(completeCheck?: boolean): boolean;
  28251. /**
  28252. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28253. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28254. * @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.
  28255. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28256. */
  28257. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28258. /**
  28259. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28260. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28261. * The `data` are either a numeric array either a Float32Array.
  28262. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28263. * 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).
  28264. * Note that a new underlying VertexBuffer object is created each call.
  28265. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28266. *
  28267. * Possible `kind` values :
  28268. * - VertexBuffer.PositionKind
  28269. * - VertexBuffer.UVKind
  28270. * - VertexBuffer.UV2Kind
  28271. * - VertexBuffer.UV3Kind
  28272. * - VertexBuffer.UV4Kind
  28273. * - VertexBuffer.UV5Kind
  28274. * - VertexBuffer.UV6Kind
  28275. * - VertexBuffer.ColorKind
  28276. * - VertexBuffer.MatricesIndicesKind
  28277. * - VertexBuffer.MatricesIndicesExtraKind
  28278. * - VertexBuffer.MatricesWeightsKind
  28279. * - VertexBuffer.MatricesWeightsExtraKind
  28280. *
  28281. * Returns the Mesh.
  28282. */
  28283. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28284. /**
  28285. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28286. * If the mesh has no geometry, it is simply returned as it is.
  28287. * The `data` are either a numeric array either a Float32Array.
  28288. * No new underlying VertexBuffer object is created.
  28289. * 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.
  28290. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28291. *
  28292. * Possible `kind` values :
  28293. * - VertexBuffer.PositionKind
  28294. * - VertexBuffer.UVKind
  28295. * - VertexBuffer.UV2Kind
  28296. * - VertexBuffer.UV3Kind
  28297. * - VertexBuffer.UV4Kind
  28298. * - VertexBuffer.UV5Kind
  28299. * - VertexBuffer.UV6Kind
  28300. * - VertexBuffer.ColorKind
  28301. * - VertexBuffer.MatricesIndicesKind
  28302. * - VertexBuffer.MatricesIndicesExtraKind
  28303. * - VertexBuffer.MatricesWeightsKind
  28304. * - VertexBuffer.MatricesWeightsExtraKind
  28305. *
  28306. * Returns the Mesh.
  28307. */
  28308. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28309. /**
  28310. * Sets the mesh indices.
  28311. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28312. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28313. * This method creates a new index buffer each call.
  28314. * Returns the Mesh.
  28315. */
  28316. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28317. /**
  28318. * Boolean : True if the mesh owns the requested kind of data.
  28319. */
  28320. isVerticesDataPresent(kind: string): boolean;
  28321. /**
  28322. * Returns an array of indices (IndicesArray).
  28323. */
  28324. getIndices(): Nullable<IndicesArray>;
  28325. get _positions(): Nullable<Vector3[]>;
  28326. /**
  28327. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28328. * This means the mesh underlying bounding box and sphere are recomputed.
  28329. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28330. * @returns the current mesh
  28331. */
  28332. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28333. /** @hidden */
  28334. _preActivate(): InstancedMesh;
  28335. /** @hidden */
  28336. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28337. /** @hidden */
  28338. _postActivate(): void;
  28339. getWorldMatrix(): Matrix;
  28340. get isAnInstance(): boolean;
  28341. /**
  28342. * Returns the current associated LOD AbstractMesh.
  28343. */
  28344. getLOD(camera: Camera): AbstractMesh;
  28345. /** @hidden */
  28346. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28347. /** @hidden */
  28348. _syncSubMeshes(): InstancedMesh;
  28349. /** @hidden */
  28350. _generatePointsArray(): boolean;
  28351. /** @hidden */
  28352. _updateBoundingInfo(): AbstractMesh;
  28353. /**
  28354. * Creates a new InstancedMesh from the current mesh.
  28355. * - name (string) : the cloned mesh name
  28356. * - newParent (optional Node) : the optional Node to parent the clone to.
  28357. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28358. *
  28359. * Returns the clone.
  28360. */
  28361. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28362. /**
  28363. * Disposes the InstancedMesh.
  28364. * Returns nothing.
  28365. */
  28366. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28367. }
  28368. interface Mesh {
  28369. /**
  28370. * Register a custom buffer that will be instanced
  28371. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28372. * @param kind defines the buffer kind
  28373. * @param stride defines the stride in floats
  28374. */
  28375. registerInstancedBuffer(kind: string, stride: number): void;
  28376. /**
  28377. * true to use the edge renderer for all instances of this mesh
  28378. */
  28379. edgesShareWithInstances: boolean;
  28380. /** @hidden */
  28381. _userInstancedBuffersStorage: {
  28382. data: {
  28383. [key: string]: Float32Array;
  28384. };
  28385. sizes: {
  28386. [key: string]: number;
  28387. };
  28388. vertexBuffers: {
  28389. [key: string]: Nullable<VertexBuffer>;
  28390. };
  28391. strides: {
  28392. [key: string]: number;
  28393. };
  28394. };
  28395. }
  28396. interface AbstractMesh {
  28397. /**
  28398. * Object used to store instanced buffers defined by user
  28399. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28400. */
  28401. instancedBuffers: {
  28402. [key: string]: any;
  28403. };
  28404. }
  28405. }
  28406. declare module BABYLON {
  28407. /**
  28408. * Defines the options associated with the creation of a shader material.
  28409. */
  28410. export interface IShaderMaterialOptions {
  28411. /**
  28412. * Does the material work in alpha blend mode
  28413. */
  28414. needAlphaBlending: boolean;
  28415. /**
  28416. * Does the material work in alpha test mode
  28417. */
  28418. needAlphaTesting: boolean;
  28419. /**
  28420. * The list of attribute names used in the shader
  28421. */
  28422. attributes: string[];
  28423. /**
  28424. * The list of unifrom names used in the shader
  28425. */
  28426. uniforms: string[];
  28427. /**
  28428. * The list of UBO names used in the shader
  28429. */
  28430. uniformBuffers: string[];
  28431. /**
  28432. * The list of sampler names used in the shader
  28433. */
  28434. samplers: string[];
  28435. /**
  28436. * The list of defines used in the shader
  28437. */
  28438. defines: string[];
  28439. }
  28440. /**
  28441. * 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.
  28442. *
  28443. * This returned material effects how the mesh will look based on the code in the shaders.
  28444. *
  28445. * @see https://doc.babylonjs.com/how_to/shader_material
  28446. */
  28447. export class ShaderMaterial extends Material {
  28448. private _shaderPath;
  28449. private _options;
  28450. private _textures;
  28451. private _textureArrays;
  28452. private _floats;
  28453. private _ints;
  28454. private _floatsArrays;
  28455. private _colors3;
  28456. private _colors3Arrays;
  28457. private _colors4;
  28458. private _colors4Arrays;
  28459. private _vectors2;
  28460. private _vectors3;
  28461. private _vectors4;
  28462. private _matrices;
  28463. private _matrixArrays;
  28464. private _matrices3x3;
  28465. private _matrices2x2;
  28466. private _vectors2Arrays;
  28467. private _vectors3Arrays;
  28468. private _vectors4Arrays;
  28469. private _cachedWorldViewMatrix;
  28470. private _cachedWorldViewProjectionMatrix;
  28471. private _renderId;
  28472. private _multiview;
  28473. private _cachedDefines;
  28474. /** Define the Url to load snippets */
  28475. static SnippetUrl: string;
  28476. /** Snippet ID if the material was created from the snippet server */
  28477. snippetId: string;
  28478. /**
  28479. * Instantiate a new shader material.
  28480. * 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.
  28481. * This returned material effects how the mesh will look based on the code in the shaders.
  28482. * @see https://doc.babylonjs.com/how_to/shader_material
  28483. * @param name Define the name of the material in the scene
  28484. * @param scene Define the scene the material belongs to
  28485. * @param shaderPath Defines the route to the shader code in one of three ways:
  28486. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28487. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28488. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28489. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28490. * @param options Define the options used to create the shader
  28491. */
  28492. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28493. /**
  28494. * Gets the shader path used to define the shader code
  28495. * It can be modified to trigger a new compilation
  28496. */
  28497. get shaderPath(): any;
  28498. /**
  28499. * Sets the shader path used to define the shader code
  28500. * It can be modified to trigger a new compilation
  28501. */
  28502. set shaderPath(shaderPath: any);
  28503. /**
  28504. * Gets the options used to compile the shader.
  28505. * They can be modified to trigger a new compilation
  28506. */
  28507. get options(): IShaderMaterialOptions;
  28508. /**
  28509. * Gets the current class name of the material e.g. "ShaderMaterial"
  28510. * Mainly use in serialization.
  28511. * @returns the class name
  28512. */
  28513. getClassName(): string;
  28514. /**
  28515. * Specifies if the material will require alpha blending
  28516. * @returns a boolean specifying if alpha blending is needed
  28517. */
  28518. needAlphaBlending(): boolean;
  28519. /**
  28520. * Specifies if this material should be rendered in alpha test mode
  28521. * @returns a boolean specifying if an alpha test is needed.
  28522. */
  28523. needAlphaTesting(): boolean;
  28524. private _checkUniform;
  28525. /**
  28526. * Set a texture in the shader.
  28527. * @param name Define the name of the uniform samplers as defined in the shader
  28528. * @param texture Define the texture to bind to this sampler
  28529. * @return the material itself allowing "fluent" like uniform updates
  28530. */
  28531. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28532. /**
  28533. * Set a texture array in the shader.
  28534. * @param name Define the name of the uniform sampler array as defined in the shader
  28535. * @param textures Define the list of textures to bind to this sampler
  28536. * @return the material itself allowing "fluent" like uniform updates
  28537. */
  28538. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28539. /**
  28540. * Set a float in the shader.
  28541. * @param name Define the name of the uniform as defined in the shader
  28542. * @param value Define the value to give to the uniform
  28543. * @return the material itself allowing "fluent" like uniform updates
  28544. */
  28545. setFloat(name: string, value: number): ShaderMaterial;
  28546. /**
  28547. * Set a int in the shader.
  28548. * @param name Define the name of the uniform as defined in the shader
  28549. * @param value Define the value to give to the uniform
  28550. * @return the material itself allowing "fluent" like uniform updates
  28551. */
  28552. setInt(name: string, value: number): ShaderMaterial;
  28553. /**
  28554. * Set an array of floats in the shader.
  28555. * @param name Define the name of the uniform as defined in the shader
  28556. * @param value Define the value to give to the uniform
  28557. * @return the material itself allowing "fluent" like uniform updates
  28558. */
  28559. setFloats(name: string, value: number[]): ShaderMaterial;
  28560. /**
  28561. * Set a vec3 in the shader from a Color3.
  28562. * @param name Define the name of the uniform as defined in the shader
  28563. * @param value Define the value to give to the uniform
  28564. * @return the material itself allowing "fluent" like uniform updates
  28565. */
  28566. setColor3(name: string, value: Color3): ShaderMaterial;
  28567. /**
  28568. * Set a vec3 array in the shader from a Color3 array.
  28569. * @param name Define the name of the uniform as defined in the shader
  28570. * @param value Define the value to give to the uniform
  28571. * @return the material itself allowing "fluent" like uniform updates
  28572. */
  28573. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28574. /**
  28575. * Set a vec4 in the shader from a Color4.
  28576. * @param name Define the name of the uniform as defined in the shader
  28577. * @param value Define the value to give to the uniform
  28578. * @return the material itself allowing "fluent" like uniform updates
  28579. */
  28580. setColor4(name: string, value: Color4): ShaderMaterial;
  28581. /**
  28582. * Set a vec4 array in the shader from a Color4 array.
  28583. * @param name Define the name of the uniform as defined in the shader
  28584. * @param value Define the value to give to the uniform
  28585. * @return the material itself allowing "fluent" like uniform updates
  28586. */
  28587. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28588. /**
  28589. * Set a vec2 in the shader from a Vector2.
  28590. * @param name Define the name of the uniform as defined in the shader
  28591. * @param value Define the value to give to the uniform
  28592. * @return the material itself allowing "fluent" like uniform updates
  28593. */
  28594. setVector2(name: string, value: Vector2): ShaderMaterial;
  28595. /**
  28596. * Set a vec3 in the shader from a Vector3.
  28597. * @param name Define the name of the uniform as defined in the shader
  28598. * @param value Define the value to give to the uniform
  28599. * @return the material itself allowing "fluent" like uniform updates
  28600. */
  28601. setVector3(name: string, value: Vector3): ShaderMaterial;
  28602. /**
  28603. * Set a vec4 in the shader from a Vector4.
  28604. * @param name Define the name of the uniform as defined in the shader
  28605. * @param value Define the value to give to the uniform
  28606. * @return the material itself allowing "fluent" like uniform updates
  28607. */
  28608. setVector4(name: string, value: Vector4): ShaderMaterial;
  28609. /**
  28610. * Set a mat4 in the shader from a Matrix.
  28611. * @param name Define the name of the uniform as defined in the shader
  28612. * @param value Define the value to give to the uniform
  28613. * @return the material itself allowing "fluent" like uniform updates
  28614. */
  28615. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28616. /**
  28617. * Set a float32Array in the shader from a matrix array.
  28618. * @param name Define the name of the uniform as defined in the shader
  28619. * @param value Define the value to give to the uniform
  28620. * @return the material itself allowing "fluent" like uniform updates
  28621. */
  28622. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28623. /**
  28624. * Set a mat3 in the shader from a Float32Array.
  28625. * @param name Define the name of the uniform as defined in the shader
  28626. * @param value Define the value to give to the uniform
  28627. * @return the material itself allowing "fluent" like uniform updates
  28628. */
  28629. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28630. /**
  28631. * Set a mat2 in the shader from a Float32Array.
  28632. * @param name Define the name of the uniform as defined in the shader
  28633. * @param value Define the value to give to the uniform
  28634. * @return the material itself allowing "fluent" like uniform updates
  28635. */
  28636. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28637. /**
  28638. * Set a vec2 array in the shader from a number array.
  28639. * @param name Define the name of the uniform as defined in the shader
  28640. * @param value Define the value to give to the uniform
  28641. * @return the material itself allowing "fluent" like uniform updates
  28642. */
  28643. setArray2(name: string, value: number[]): ShaderMaterial;
  28644. /**
  28645. * Set a vec3 array in the shader from a number array.
  28646. * @param name Define the name of the uniform as defined in the shader
  28647. * @param value Define the value to give to the uniform
  28648. * @return the material itself allowing "fluent" like uniform updates
  28649. */
  28650. setArray3(name: string, value: number[]): ShaderMaterial;
  28651. /**
  28652. * Set a vec4 array in the shader from a number array.
  28653. * @param name Define the name of the uniform as defined in the shader
  28654. * @param value Define the value to give to the uniform
  28655. * @return the material itself allowing "fluent" like uniform updates
  28656. */
  28657. setArray4(name: string, value: number[]): ShaderMaterial;
  28658. private _checkCache;
  28659. /**
  28660. * Specifies that the submesh is ready to be used
  28661. * @param mesh defines the mesh to check
  28662. * @param subMesh defines which submesh to check
  28663. * @param useInstances specifies that instances should be used
  28664. * @returns a boolean indicating that the submesh is ready or not
  28665. */
  28666. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28667. /**
  28668. * Checks if the material is ready to render the requested mesh
  28669. * @param mesh Define the mesh to render
  28670. * @param useInstances Define whether or not the material is used with instances
  28671. * @returns true if ready, otherwise false
  28672. */
  28673. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  28674. /**
  28675. * Binds the world matrix to the material
  28676. * @param world defines the world transformation matrix
  28677. * @param effectOverride - If provided, use this effect instead of internal effect
  28678. */
  28679. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  28680. /**
  28681. * Binds the submesh to this material by preparing the effect and shader to draw
  28682. * @param world defines the world transformation matrix
  28683. * @param mesh defines the mesh containing the submesh
  28684. * @param subMesh defines the submesh to bind the material to
  28685. */
  28686. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28687. /**
  28688. * Binds the material to the mesh
  28689. * @param world defines the world transformation matrix
  28690. * @param mesh defines the mesh to bind the material to
  28691. * @param effectOverride - If provided, use this effect instead of internal effect
  28692. */
  28693. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  28694. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  28695. /**
  28696. * Gets the active textures from the material
  28697. * @returns an array of textures
  28698. */
  28699. getActiveTextures(): BaseTexture[];
  28700. /**
  28701. * Specifies if the material uses a texture
  28702. * @param texture defines the texture to check against the material
  28703. * @returns a boolean specifying if the material uses the texture
  28704. */
  28705. hasTexture(texture: BaseTexture): boolean;
  28706. /**
  28707. * Makes a duplicate of the material, and gives it a new name
  28708. * @param name defines the new name for the duplicated material
  28709. * @returns the cloned material
  28710. */
  28711. clone(name: string): ShaderMaterial;
  28712. /**
  28713. * Disposes the material
  28714. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28715. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28716. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  28717. */
  28718. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  28719. /**
  28720. * Serializes this material in a JSON representation
  28721. * @returns the serialized material object
  28722. */
  28723. serialize(): any;
  28724. /**
  28725. * Creates a shader material from parsed shader material data
  28726. * @param source defines the JSON represnetation of the material
  28727. * @param scene defines the hosting scene
  28728. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28729. * @returns a new material
  28730. */
  28731. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28732. /**
  28733. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28734. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28735. * @param url defines the url to load from
  28736. * @param scene defines the hosting scene
  28737. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28738. * @returns a promise that will resolve to the new ShaderMaterial
  28739. */
  28740. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28741. /**
  28742. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28743. * @param snippetId defines the snippet to load
  28744. * @param scene defines the hosting scene
  28745. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28746. * @returns a promise that will resolve to the new ShaderMaterial
  28747. */
  28748. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28749. }
  28750. }
  28751. declare module BABYLON {
  28752. /** @hidden */
  28753. export var colorPixelShader: {
  28754. name: string;
  28755. shader: string;
  28756. };
  28757. }
  28758. declare module BABYLON {
  28759. /** @hidden */
  28760. export var colorVertexShader: {
  28761. name: string;
  28762. shader: string;
  28763. };
  28764. }
  28765. declare module BABYLON {
  28766. /**
  28767. * Line mesh
  28768. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28769. */
  28770. export class LinesMesh extends Mesh {
  28771. /**
  28772. * If vertex color should be applied to the mesh
  28773. */
  28774. readonly useVertexColor?: boolean | undefined;
  28775. /**
  28776. * If vertex alpha should be applied to the mesh
  28777. */
  28778. readonly useVertexAlpha?: boolean | undefined;
  28779. /**
  28780. * Color of the line (Default: White)
  28781. */
  28782. color: Color3;
  28783. /**
  28784. * Alpha of the line (Default: 1)
  28785. */
  28786. alpha: number;
  28787. /**
  28788. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28789. * This margin is expressed in world space coordinates, so its value may vary.
  28790. * Default value is 0.1
  28791. */
  28792. intersectionThreshold: number;
  28793. private _colorShader;
  28794. private color4;
  28795. /**
  28796. * Creates a new LinesMesh
  28797. * @param name defines the name
  28798. * @param scene defines the hosting scene
  28799. * @param parent defines the parent mesh if any
  28800. * @param source defines the optional source LinesMesh used to clone data from
  28801. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28802. * When false, achieved by calling a clone(), also passing False.
  28803. * This will make creation of children, recursive.
  28804. * @param useVertexColor defines if this LinesMesh supports vertex color
  28805. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28806. */
  28807. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28808. /**
  28809. * If vertex color should be applied to the mesh
  28810. */
  28811. useVertexColor?: boolean | undefined,
  28812. /**
  28813. * If vertex alpha should be applied to the mesh
  28814. */
  28815. useVertexAlpha?: boolean | undefined);
  28816. private _addClipPlaneDefine;
  28817. private _removeClipPlaneDefine;
  28818. isReady(): boolean;
  28819. /**
  28820. * Returns the string "LineMesh"
  28821. */
  28822. getClassName(): string;
  28823. /**
  28824. * @hidden
  28825. */
  28826. get material(): Material;
  28827. /**
  28828. * @hidden
  28829. */
  28830. set material(value: Material);
  28831. /**
  28832. * @hidden
  28833. */
  28834. get checkCollisions(): boolean;
  28835. set checkCollisions(value: boolean);
  28836. /** @hidden */
  28837. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28838. /** @hidden */
  28839. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28840. /**
  28841. * Disposes of the line mesh
  28842. * @param doNotRecurse If children should be disposed
  28843. */
  28844. dispose(doNotRecurse?: boolean): void;
  28845. /**
  28846. * Returns a new LineMesh object cloned from the current one.
  28847. */
  28848. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28849. /**
  28850. * Creates a new InstancedLinesMesh object from the mesh model.
  28851. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28852. * @param name defines the name of the new instance
  28853. * @returns a new InstancedLinesMesh
  28854. */
  28855. createInstance(name: string): InstancedLinesMesh;
  28856. }
  28857. /**
  28858. * Creates an instance based on a source LinesMesh
  28859. */
  28860. export class InstancedLinesMesh extends InstancedMesh {
  28861. /**
  28862. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28863. * This margin is expressed in world space coordinates, so its value may vary.
  28864. * Initilized with the intersectionThreshold value of the source LinesMesh
  28865. */
  28866. intersectionThreshold: number;
  28867. constructor(name: string, source: LinesMesh);
  28868. /**
  28869. * Returns the string "InstancedLinesMesh".
  28870. */
  28871. getClassName(): string;
  28872. }
  28873. }
  28874. declare module BABYLON {
  28875. /** @hidden */
  28876. export var linePixelShader: {
  28877. name: string;
  28878. shader: string;
  28879. };
  28880. }
  28881. declare module BABYLON {
  28882. /** @hidden */
  28883. export var lineVertexShader: {
  28884. name: string;
  28885. shader: string;
  28886. };
  28887. }
  28888. declare module BABYLON {
  28889. interface Scene {
  28890. /** @hidden */
  28891. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28892. }
  28893. interface AbstractMesh {
  28894. /**
  28895. * Gets the edgesRenderer associated with the mesh
  28896. */
  28897. edgesRenderer: Nullable<EdgesRenderer>;
  28898. }
  28899. interface LinesMesh {
  28900. /**
  28901. * Enables the edge rendering mode on the mesh.
  28902. * This mode makes the mesh edges visible
  28903. * @param epsilon defines the maximal distance between two angles to detect a face
  28904. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28905. * @returns the currentAbstractMesh
  28906. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28907. */
  28908. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28909. }
  28910. interface InstancedLinesMesh {
  28911. /**
  28912. * Enables the edge rendering mode on the mesh.
  28913. * This mode makes the mesh edges visible
  28914. * @param epsilon defines the maximal distance between two angles to detect a face
  28915. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28916. * @returns the current InstancedLinesMesh
  28917. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28918. */
  28919. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28920. }
  28921. /**
  28922. * Defines the minimum contract an Edges renderer should follow.
  28923. */
  28924. export interface IEdgesRenderer extends IDisposable {
  28925. /**
  28926. * Gets or sets a boolean indicating if the edgesRenderer is active
  28927. */
  28928. isEnabled: boolean;
  28929. /**
  28930. * Renders the edges of the attached mesh,
  28931. */
  28932. render(): void;
  28933. /**
  28934. * Checks wether or not the edges renderer is ready to render.
  28935. * @return true if ready, otherwise false.
  28936. */
  28937. isReady(): boolean;
  28938. /**
  28939. * List of instances to render in case the source mesh has instances
  28940. */
  28941. customInstances: SmartArray<Matrix>;
  28942. }
  28943. /**
  28944. * Defines the additional options of the edges renderer
  28945. */
  28946. export interface IEdgesRendererOptions {
  28947. /**
  28948. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28949. * If not defined, the default value is true
  28950. */
  28951. useAlternateEdgeFinder?: boolean;
  28952. /**
  28953. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28954. * If not defined, the default value is true.
  28955. * 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)
  28956. * This option is used only if useAlternateEdgeFinder = true
  28957. */
  28958. useFastVertexMerger?: boolean;
  28959. /**
  28960. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28961. * The default value is 1e-6
  28962. * This option is used only if useAlternateEdgeFinder = true
  28963. */
  28964. epsilonVertexMerge?: number;
  28965. /**
  28966. * 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
  28967. * 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.
  28968. * This option is used only if useAlternateEdgeFinder = true
  28969. */
  28970. applyTessellation?: boolean;
  28971. /**
  28972. * 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
  28973. * The default value is 1e-6
  28974. * This option is used only if useAlternateEdgeFinder = true
  28975. */
  28976. epsilonVertexAligned?: number;
  28977. }
  28978. /**
  28979. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28980. */
  28981. export class EdgesRenderer implements IEdgesRenderer {
  28982. /**
  28983. * Define the size of the edges with an orthographic camera
  28984. */
  28985. edgesWidthScalerForOrthographic: number;
  28986. /**
  28987. * Define the size of the edges with a perspective camera
  28988. */
  28989. edgesWidthScalerForPerspective: number;
  28990. protected _source: AbstractMesh;
  28991. protected _linesPositions: number[];
  28992. protected _linesNormals: number[];
  28993. protected _linesIndices: number[];
  28994. protected _epsilon: number;
  28995. protected _indicesCount: number;
  28996. protected _lineShader: ShaderMaterial;
  28997. protected _ib: DataBuffer;
  28998. protected _buffers: {
  28999. [key: string]: Nullable<VertexBuffer>;
  29000. };
  29001. protected _buffersForInstances: {
  29002. [key: string]: Nullable<VertexBuffer>;
  29003. };
  29004. protected _checkVerticesInsteadOfIndices: boolean;
  29005. protected _options: Nullable<IEdgesRendererOptions>;
  29006. private _meshRebuildObserver;
  29007. private _meshDisposeObserver;
  29008. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29009. isEnabled: boolean;
  29010. /** Gets the vertices generated by the edge renderer */
  29011. get linesPositions(): Immutable<Array<number>>;
  29012. /** Gets the normals generated by the edge renderer */
  29013. get linesNormals(): Immutable<Array<number>>;
  29014. /** Gets the indices generated by the edge renderer */
  29015. get linesIndices(): Immutable<Array<number>>;
  29016. /**
  29017. * List of instances to render in case the source mesh has instances
  29018. */
  29019. customInstances: SmartArray<Matrix>;
  29020. private static GetShader;
  29021. /**
  29022. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29023. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29024. * @param source Mesh used to create edges
  29025. * @param epsilon sum of angles in adjacency to check for edge
  29026. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29027. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29028. * @param options The options to apply when generating the edges
  29029. */
  29030. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29031. protected _prepareRessources(): void;
  29032. /** @hidden */
  29033. _rebuild(): void;
  29034. /**
  29035. * Releases the required resources for the edges renderer
  29036. */
  29037. dispose(): void;
  29038. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29039. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29040. /**
  29041. * Checks if the pair of p0 and p1 is en edge
  29042. * @param faceIndex
  29043. * @param edge
  29044. * @param faceNormals
  29045. * @param p0
  29046. * @param p1
  29047. * @private
  29048. */
  29049. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29050. /**
  29051. * push line into the position, normal and index buffer
  29052. * @protected
  29053. */
  29054. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29055. /**
  29056. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29057. */
  29058. private _tessellateTriangle;
  29059. private _generateEdgesLinesAlternate;
  29060. /**
  29061. * Generates lines edges from adjacencjes
  29062. * @private
  29063. */
  29064. _generateEdgesLines(): void;
  29065. /**
  29066. * Checks wether or not the edges renderer is ready to render.
  29067. * @return true if ready, otherwise false.
  29068. */
  29069. isReady(): boolean;
  29070. /**
  29071. * Renders the edges of the attached mesh,
  29072. */
  29073. render(): void;
  29074. }
  29075. /**
  29076. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29077. */
  29078. export class LineEdgesRenderer extends EdgesRenderer {
  29079. /**
  29080. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29081. * @param source LineMesh used to generate edges
  29082. * @param epsilon not important (specified angle for edge detection)
  29083. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29084. */
  29085. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29086. /**
  29087. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29088. */
  29089. _generateEdgesLines(): void;
  29090. }
  29091. }
  29092. declare module BABYLON {
  29093. /**
  29094. * This represents the object necessary to create a rendering group.
  29095. * This is exclusively used and created by the rendering manager.
  29096. * To modify the behavior, you use the available helpers in your scene or meshes.
  29097. * @hidden
  29098. */
  29099. export class RenderingGroup {
  29100. index: number;
  29101. private static _zeroVector;
  29102. private _scene;
  29103. private _opaqueSubMeshes;
  29104. private _transparentSubMeshes;
  29105. private _alphaTestSubMeshes;
  29106. private _depthOnlySubMeshes;
  29107. private _particleSystems;
  29108. private _spriteManagers;
  29109. private _opaqueSortCompareFn;
  29110. private _alphaTestSortCompareFn;
  29111. private _transparentSortCompareFn;
  29112. private _renderOpaque;
  29113. private _renderAlphaTest;
  29114. private _renderTransparent;
  29115. /** @hidden */
  29116. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29117. onBeforeTransparentRendering: () => void;
  29118. /**
  29119. * Set the opaque sort comparison function.
  29120. * If null the sub meshes will be render in the order they were created
  29121. */
  29122. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29123. /**
  29124. * Set the alpha test sort comparison function.
  29125. * If null the sub meshes will be render in the order they were created
  29126. */
  29127. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29128. /**
  29129. * Set the transparent sort comparison function.
  29130. * If null the sub meshes will be render in the order they were created
  29131. */
  29132. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29133. /**
  29134. * Creates a new rendering group.
  29135. * @param index The rendering group index
  29136. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29137. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29138. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29139. */
  29140. 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>);
  29141. /**
  29142. * Render all the sub meshes contained in the group.
  29143. * @param customRenderFunction Used to override the default render behaviour of the group.
  29144. * @returns true if rendered some submeshes.
  29145. */
  29146. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29147. /**
  29148. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29149. * @param subMeshes The submeshes to render
  29150. */
  29151. private renderOpaqueSorted;
  29152. /**
  29153. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29154. * @param subMeshes The submeshes to render
  29155. */
  29156. private renderAlphaTestSorted;
  29157. /**
  29158. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29159. * @param subMeshes The submeshes to render
  29160. */
  29161. private renderTransparentSorted;
  29162. /**
  29163. * Renders the submeshes in a specified order.
  29164. * @param subMeshes The submeshes to sort before render
  29165. * @param sortCompareFn The comparison function use to sort
  29166. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29167. * @param transparent Specifies to activate blending if true
  29168. */
  29169. private static renderSorted;
  29170. /**
  29171. * Renders the submeshes in the order they were dispatched (no sort applied).
  29172. * @param subMeshes The submeshes to render
  29173. */
  29174. private static renderUnsorted;
  29175. /**
  29176. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29177. * are rendered back to front if in the same alpha index.
  29178. *
  29179. * @param a The first submesh
  29180. * @param b The second submesh
  29181. * @returns The result of the comparison
  29182. */
  29183. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29184. /**
  29185. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29186. * are rendered back to front.
  29187. *
  29188. * @param a The first submesh
  29189. * @param b The second submesh
  29190. * @returns The result of the comparison
  29191. */
  29192. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29193. /**
  29194. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29195. * are rendered front to back (prevent overdraw).
  29196. *
  29197. * @param a The first submesh
  29198. * @param b The second submesh
  29199. * @returns The result of the comparison
  29200. */
  29201. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29202. /**
  29203. * Resets the different lists of submeshes to prepare a new frame.
  29204. */
  29205. prepare(): void;
  29206. dispose(): void;
  29207. /**
  29208. * Inserts the submesh in its correct queue depending on its material.
  29209. * @param subMesh The submesh to dispatch
  29210. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29211. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29212. */
  29213. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29214. dispatchSprites(spriteManager: ISpriteManager): void;
  29215. dispatchParticles(particleSystem: IParticleSystem): void;
  29216. private _renderParticles;
  29217. private _renderSprites;
  29218. }
  29219. }
  29220. declare module BABYLON {
  29221. /**
  29222. * Interface describing the different options available in the rendering manager
  29223. * regarding Auto Clear between groups.
  29224. */
  29225. export interface IRenderingManagerAutoClearSetup {
  29226. /**
  29227. * Defines whether or not autoclear is enable.
  29228. */
  29229. autoClear: boolean;
  29230. /**
  29231. * Defines whether or not to autoclear the depth buffer.
  29232. */
  29233. depth: boolean;
  29234. /**
  29235. * Defines whether or not to autoclear the stencil buffer.
  29236. */
  29237. stencil: boolean;
  29238. }
  29239. /**
  29240. * This class is used by the onRenderingGroupObservable
  29241. */
  29242. export class RenderingGroupInfo {
  29243. /**
  29244. * The Scene that being rendered
  29245. */
  29246. scene: Scene;
  29247. /**
  29248. * The camera currently used for the rendering pass
  29249. */
  29250. camera: Nullable<Camera>;
  29251. /**
  29252. * The ID of the renderingGroup being processed
  29253. */
  29254. renderingGroupId: number;
  29255. }
  29256. /**
  29257. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29258. * It is enable to manage the different groups as well as the different necessary sort functions.
  29259. * This should not be used directly aside of the few static configurations
  29260. */
  29261. export class RenderingManager {
  29262. /**
  29263. * The max id used for rendering groups (not included)
  29264. */
  29265. static MAX_RENDERINGGROUPS: number;
  29266. /**
  29267. * The min id used for rendering groups (included)
  29268. */
  29269. static MIN_RENDERINGGROUPS: number;
  29270. /**
  29271. * Used to globally prevent autoclearing scenes.
  29272. */
  29273. static AUTOCLEAR: boolean;
  29274. /**
  29275. * @hidden
  29276. */
  29277. _useSceneAutoClearSetup: boolean;
  29278. private _scene;
  29279. private _renderingGroups;
  29280. private _depthStencilBufferAlreadyCleaned;
  29281. private _autoClearDepthStencil;
  29282. private _customOpaqueSortCompareFn;
  29283. private _customAlphaTestSortCompareFn;
  29284. private _customTransparentSortCompareFn;
  29285. private _renderingGroupInfo;
  29286. /**
  29287. * Instantiates a new rendering group for a particular scene
  29288. * @param scene Defines the scene the groups belongs to
  29289. */
  29290. constructor(scene: Scene);
  29291. private _clearDepthStencilBuffer;
  29292. /**
  29293. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29294. * @hidden
  29295. */
  29296. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29297. /**
  29298. * Resets the different information of the group to prepare a new frame
  29299. * @hidden
  29300. */
  29301. reset(): void;
  29302. /**
  29303. * Dispose and release the group and its associated resources.
  29304. * @hidden
  29305. */
  29306. dispose(): void;
  29307. /**
  29308. * Clear the info related to rendering groups preventing retention points during dispose.
  29309. */
  29310. freeRenderingGroups(): void;
  29311. private _prepareRenderingGroup;
  29312. /**
  29313. * Add a sprite manager to the rendering manager in order to render it this frame.
  29314. * @param spriteManager Define the sprite manager to render
  29315. */
  29316. dispatchSprites(spriteManager: ISpriteManager): void;
  29317. /**
  29318. * Add a particle system to the rendering manager in order to render it this frame.
  29319. * @param particleSystem Define the particle system to render
  29320. */
  29321. dispatchParticles(particleSystem: IParticleSystem): void;
  29322. /**
  29323. * Add a submesh to the manager in order to render it this frame
  29324. * @param subMesh The submesh to dispatch
  29325. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29326. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29327. */
  29328. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29329. /**
  29330. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29331. * This allowed control for front to back rendering or reversly depending of the special needs.
  29332. *
  29333. * @param renderingGroupId The rendering group id corresponding to its index
  29334. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29335. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29336. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29337. */
  29338. 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;
  29339. /**
  29340. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29341. *
  29342. * @param renderingGroupId The rendering group id corresponding to its index
  29343. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29344. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29345. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29346. */
  29347. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29348. /**
  29349. * Gets the current auto clear configuration for one rendering group of the rendering
  29350. * manager.
  29351. * @param index the rendering group index to get the information for
  29352. * @returns The auto clear setup for the requested rendering group
  29353. */
  29354. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29355. }
  29356. }
  29357. declare module BABYLON {
  29358. /**
  29359. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29360. */
  29361. export interface ICustomShaderOptions {
  29362. /**
  29363. * Gets or sets the custom shader name to use
  29364. */
  29365. shaderName: string;
  29366. /**
  29367. * The list of attribute names used in the shader
  29368. */
  29369. attributes?: string[];
  29370. /**
  29371. * The list of unifrom names used in the shader
  29372. */
  29373. uniforms?: string[];
  29374. /**
  29375. * The list of sampler names used in the shader
  29376. */
  29377. samplers?: string[];
  29378. /**
  29379. * The list of defines used in the shader
  29380. */
  29381. defines?: string[];
  29382. }
  29383. /**
  29384. * Interface to implement to create a shadow generator compatible with BJS.
  29385. */
  29386. export interface IShadowGenerator {
  29387. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29388. id: string;
  29389. /**
  29390. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29391. * @returns The render target texture if present otherwise, null
  29392. */
  29393. getShadowMap(): Nullable<RenderTargetTexture>;
  29394. /**
  29395. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29396. * @param subMesh The submesh we want to render in the shadow map
  29397. * @param useInstances Defines wether will draw in the map using instances
  29398. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29399. * @returns true if ready otherwise, false
  29400. */
  29401. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29402. /**
  29403. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29404. * @param defines Defines of the material we want to update
  29405. * @param lightIndex Index of the light in the enabled light list of the material
  29406. */
  29407. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29408. /**
  29409. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29410. * defined in the generator but impacting the effect).
  29411. * It implies the unifroms available on the materials are the standard BJS ones.
  29412. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29413. * @param effect The effect we are binfing the information for
  29414. */
  29415. bindShadowLight(lightIndex: string, effect: Effect): void;
  29416. /**
  29417. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29418. * (eq to shadow prjection matrix * light transform matrix)
  29419. * @returns The transform matrix used to create the shadow map
  29420. */
  29421. getTransformMatrix(): Matrix;
  29422. /**
  29423. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29424. * Cube and 2D textures for instance.
  29425. */
  29426. recreateShadowMap(): void;
  29427. /**
  29428. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29429. * @param onCompiled Callback triggered at the and of the effects compilation
  29430. * @param options Sets of optional options forcing the compilation with different modes
  29431. */
  29432. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29433. useInstances: boolean;
  29434. }>): void;
  29435. /**
  29436. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29437. * @param options Sets of optional options forcing the compilation with different modes
  29438. * @returns A promise that resolves when the compilation completes
  29439. */
  29440. forceCompilationAsync(options?: Partial<{
  29441. useInstances: boolean;
  29442. }>): Promise<void>;
  29443. /**
  29444. * Serializes the shadow generator setup to a json object.
  29445. * @returns The serialized JSON object
  29446. */
  29447. serialize(): any;
  29448. /**
  29449. * Disposes the Shadow map and related Textures and effects.
  29450. */
  29451. dispose(): void;
  29452. }
  29453. /**
  29454. * Default implementation IShadowGenerator.
  29455. * This is the main object responsible of generating shadows in the framework.
  29456. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29457. */
  29458. export class ShadowGenerator implements IShadowGenerator {
  29459. private static _Counter;
  29460. /**
  29461. * Name of the shadow generator class
  29462. */
  29463. static CLASSNAME: string;
  29464. /**
  29465. * Shadow generator mode None: no filtering applied.
  29466. */
  29467. static readonly FILTER_NONE: number;
  29468. /**
  29469. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29470. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29471. */
  29472. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29473. /**
  29474. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29475. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29476. */
  29477. static readonly FILTER_POISSONSAMPLING: number;
  29478. /**
  29479. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29480. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29481. */
  29482. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29483. /**
  29484. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29485. * edge artifacts on steep falloff.
  29486. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29487. */
  29488. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29489. /**
  29490. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29491. * edge artifacts on steep falloff.
  29492. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29493. */
  29494. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29495. /**
  29496. * Shadow generator mode PCF: Percentage Closer Filtering
  29497. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29498. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29499. */
  29500. static readonly FILTER_PCF: number;
  29501. /**
  29502. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29503. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29504. * Contact Hardening
  29505. */
  29506. static readonly FILTER_PCSS: number;
  29507. /**
  29508. * Reserved for PCF and PCSS
  29509. * Highest Quality.
  29510. *
  29511. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29512. *
  29513. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29514. */
  29515. static readonly QUALITY_HIGH: number;
  29516. /**
  29517. * Reserved for PCF and PCSS
  29518. * Good tradeoff for quality/perf cross devices
  29519. *
  29520. * Execute PCF on a 3*3 kernel.
  29521. *
  29522. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29523. */
  29524. static readonly QUALITY_MEDIUM: number;
  29525. /**
  29526. * Reserved for PCF and PCSS
  29527. * The lowest quality but the fastest.
  29528. *
  29529. * Execute PCF on a 1*1 kernel.
  29530. *
  29531. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29532. */
  29533. static readonly QUALITY_LOW: number;
  29534. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29535. id: string;
  29536. /** Gets or sets the custom shader name to use */
  29537. customShaderOptions: ICustomShaderOptions;
  29538. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29539. customAllowRendering: (subMesh: SubMesh) => boolean;
  29540. /**
  29541. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29542. */
  29543. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29544. /**
  29545. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29546. */
  29547. onAfterShadowMapRenderObservable: Observable<Effect>;
  29548. /**
  29549. * Observable triggered before a mesh is rendered in the shadow map.
  29550. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29551. */
  29552. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29553. /**
  29554. * Observable triggered after a mesh is rendered in the shadow map.
  29555. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29556. */
  29557. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29558. protected _bias: number;
  29559. /**
  29560. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29561. */
  29562. get bias(): number;
  29563. /**
  29564. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29565. */
  29566. set bias(bias: number);
  29567. protected _normalBias: number;
  29568. /**
  29569. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29570. */
  29571. get normalBias(): number;
  29572. /**
  29573. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29574. */
  29575. set normalBias(normalBias: number);
  29576. protected _blurBoxOffset: number;
  29577. /**
  29578. * Gets the blur box offset: offset applied during the blur pass.
  29579. * Only useful if useKernelBlur = false
  29580. */
  29581. get blurBoxOffset(): number;
  29582. /**
  29583. * Sets the blur box offset: offset applied during the blur pass.
  29584. * Only useful if useKernelBlur = false
  29585. */
  29586. set blurBoxOffset(value: number);
  29587. protected _blurScale: number;
  29588. /**
  29589. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29590. * 2 means half of the size.
  29591. */
  29592. get blurScale(): number;
  29593. /**
  29594. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29595. * 2 means half of the size.
  29596. */
  29597. set blurScale(value: number);
  29598. protected _blurKernel: number;
  29599. /**
  29600. * Gets the blur kernel: kernel size of the blur pass.
  29601. * Only useful if useKernelBlur = true
  29602. */
  29603. get blurKernel(): number;
  29604. /**
  29605. * Sets the blur kernel: kernel size of the blur pass.
  29606. * Only useful if useKernelBlur = true
  29607. */
  29608. set blurKernel(value: number);
  29609. protected _useKernelBlur: boolean;
  29610. /**
  29611. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29612. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29613. */
  29614. get useKernelBlur(): boolean;
  29615. /**
  29616. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29617. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29618. */
  29619. set useKernelBlur(value: boolean);
  29620. protected _depthScale: number;
  29621. /**
  29622. * Gets the depth scale used in ESM mode.
  29623. */
  29624. get depthScale(): number;
  29625. /**
  29626. * Sets the depth scale used in ESM mode.
  29627. * This can override the scale stored on the light.
  29628. */
  29629. set depthScale(value: number);
  29630. protected _validateFilter(filter: number): number;
  29631. protected _filter: number;
  29632. /**
  29633. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29634. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29635. */
  29636. get filter(): number;
  29637. /**
  29638. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29639. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29640. */
  29641. set filter(value: number);
  29642. /**
  29643. * Gets if the current filter is set to Poisson Sampling.
  29644. */
  29645. get usePoissonSampling(): boolean;
  29646. /**
  29647. * Sets the current filter to Poisson Sampling.
  29648. */
  29649. set usePoissonSampling(value: boolean);
  29650. /**
  29651. * Gets if the current filter is set to ESM.
  29652. */
  29653. get useExponentialShadowMap(): boolean;
  29654. /**
  29655. * Sets the current filter is to ESM.
  29656. */
  29657. set useExponentialShadowMap(value: boolean);
  29658. /**
  29659. * Gets if the current filter is set to filtered ESM.
  29660. */
  29661. get useBlurExponentialShadowMap(): boolean;
  29662. /**
  29663. * Gets if the current filter is set to filtered ESM.
  29664. */
  29665. set useBlurExponentialShadowMap(value: boolean);
  29666. /**
  29667. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29668. * exponential to prevent steep falloff artifacts).
  29669. */
  29670. get useCloseExponentialShadowMap(): boolean;
  29671. /**
  29672. * Sets the current filter to "close ESM" (using the inverse of the
  29673. * exponential to prevent steep falloff artifacts).
  29674. */
  29675. set useCloseExponentialShadowMap(value: boolean);
  29676. /**
  29677. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29678. * exponential to prevent steep falloff artifacts).
  29679. */
  29680. get useBlurCloseExponentialShadowMap(): boolean;
  29681. /**
  29682. * Sets the current filter to filtered "close ESM" (using the inverse of the
  29683. * exponential to prevent steep falloff artifacts).
  29684. */
  29685. set useBlurCloseExponentialShadowMap(value: boolean);
  29686. /**
  29687. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  29688. */
  29689. get usePercentageCloserFiltering(): boolean;
  29690. /**
  29691. * Sets the current filter to "PCF" (percentage closer filtering).
  29692. */
  29693. set usePercentageCloserFiltering(value: boolean);
  29694. protected _filteringQuality: number;
  29695. /**
  29696. * Gets the PCF or PCSS Quality.
  29697. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29698. */
  29699. get filteringQuality(): number;
  29700. /**
  29701. * Sets the PCF or PCSS Quality.
  29702. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29703. */
  29704. set filteringQuality(filteringQuality: number);
  29705. /**
  29706. * Gets if the current filter is set to "PCSS" (contact hardening).
  29707. */
  29708. get useContactHardeningShadow(): boolean;
  29709. /**
  29710. * Sets the current filter to "PCSS" (contact hardening).
  29711. */
  29712. set useContactHardeningShadow(value: boolean);
  29713. protected _contactHardeningLightSizeUVRatio: number;
  29714. /**
  29715. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29716. * Using a ratio helps keeping shape stability independently of the map size.
  29717. *
  29718. * It does not account for the light projection as it was having too much
  29719. * instability during the light setup or during light position changes.
  29720. *
  29721. * Only valid if useContactHardeningShadow is true.
  29722. */
  29723. get contactHardeningLightSizeUVRatio(): number;
  29724. /**
  29725. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29726. * Using a ratio helps keeping shape stability independently of the map size.
  29727. *
  29728. * It does not account for the light projection as it was having too much
  29729. * instability during the light setup or during light position changes.
  29730. *
  29731. * Only valid if useContactHardeningShadow is true.
  29732. */
  29733. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29734. protected _darkness: number;
  29735. /** Gets or sets the actual darkness of a shadow */
  29736. get darkness(): number;
  29737. set darkness(value: number);
  29738. /**
  29739. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29740. * 0 means strongest and 1 would means no shadow.
  29741. * @returns the darkness.
  29742. */
  29743. getDarkness(): number;
  29744. /**
  29745. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29746. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29747. * @returns the shadow generator allowing fluent coding.
  29748. */
  29749. setDarkness(darkness: number): ShadowGenerator;
  29750. protected _transparencyShadow: boolean;
  29751. /** Gets or sets the ability to have transparent shadow */
  29752. get transparencyShadow(): boolean;
  29753. set transparencyShadow(value: boolean);
  29754. /**
  29755. * Sets the ability to have transparent shadow (boolean).
  29756. * @param transparent True if transparent else False
  29757. * @returns the shadow generator allowing fluent coding
  29758. */
  29759. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29760. /**
  29761. * Enables or disables shadows with varying strength based on the transparency
  29762. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29763. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29764. * mesh.visibility * alphaTexture.a
  29765. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29766. */
  29767. enableSoftTransparentShadow: boolean;
  29768. protected _shadowMap: Nullable<RenderTargetTexture>;
  29769. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29770. /**
  29771. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29772. * @returns The render target texture if present otherwise, null
  29773. */
  29774. getShadowMap(): Nullable<RenderTargetTexture>;
  29775. /**
  29776. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29777. * @returns The render target texture if the shadow map is present otherwise, null
  29778. */
  29779. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29780. /**
  29781. * Gets the class name of that object
  29782. * @returns "ShadowGenerator"
  29783. */
  29784. getClassName(): string;
  29785. /**
  29786. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29787. * @param mesh Mesh to add
  29788. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29789. * @returns the Shadow Generator itself
  29790. */
  29791. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29792. /**
  29793. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29794. * @param mesh Mesh to remove
  29795. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29796. * @returns the Shadow Generator itself
  29797. */
  29798. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29799. /**
  29800. * Controls the extent to which the shadows fade out at the edge of the frustum
  29801. */
  29802. frustumEdgeFalloff: number;
  29803. protected _light: IShadowLight;
  29804. /**
  29805. * Returns the associated light object.
  29806. * @returns the light generating the shadow
  29807. */
  29808. getLight(): IShadowLight;
  29809. /**
  29810. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29811. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29812. * It might on the other hand introduce peter panning.
  29813. */
  29814. forceBackFacesOnly: boolean;
  29815. protected _scene: Scene;
  29816. protected _lightDirection: Vector3;
  29817. protected _viewMatrix: Matrix;
  29818. protected _projectionMatrix: Matrix;
  29819. protected _transformMatrix: Matrix;
  29820. protected _cachedPosition: Vector3;
  29821. protected _cachedDirection: Vector3;
  29822. protected _cachedDefines: string;
  29823. protected _currentRenderID: number;
  29824. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29825. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29826. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29827. protected _blurPostProcesses: PostProcess[];
  29828. protected _mapSize: number;
  29829. protected _currentFaceIndex: number;
  29830. protected _currentFaceIndexCache: number;
  29831. protected _textureType: number;
  29832. protected _defaultTextureMatrix: Matrix;
  29833. protected _storedUniqueId: Nullable<number>;
  29834. protected _nameForCustomEffect: string;
  29835. /** @hidden */
  29836. static _SceneComponentInitialization: (scene: Scene) => void;
  29837. /**
  29838. * Gets or sets the size of the texture what stores the shadows
  29839. */
  29840. get mapSize(): number;
  29841. set mapSize(size: number);
  29842. /**
  29843. * Creates a ShadowGenerator object.
  29844. * A ShadowGenerator is the required tool to use the shadows.
  29845. * Each light casting shadows needs to use its own ShadowGenerator.
  29846. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29847. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29848. * @param light The light object generating the shadows.
  29849. * @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.
  29850. */
  29851. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29852. protected _initializeGenerator(): void;
  29853. protected _createTargetRenderTexture(): void;
  29854. protected _initializeShadowMap(): void;
  29855. protected _initializeBlurRTTAndPostProcesses(): void;
  29856. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29857. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29858. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29859. protected _applyFilterValues(): void;
  29860. /**
  29861. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29862. * @param onCompiled Callback triggered at the and of the effects compilation
  29863. * @param options Sets of optional options forcing the compilation with different modes
  29864. */
  29865. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29866. useInstances: boolean;
  29867. }>): void;
  29868. /**
  29869. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29870. * @param options Sets of optional options forcing the compilation with different modes
  29871. * @returns A promise that resolves when the compilation completes
  29872. */
  29873. forceCompilationAsync(options?: Partial<{
  29874. useInstances: boolean;
  29875. }>): Promise<void>;
  29876. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29877. private _prepareShadowDefines;
  29878. /**
  29879. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29880. * @param subMesh The submesh we want to render in the shadow map
  29881. * @param useInstances Defines wether will draw in the map using instances
  29882. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29883. * @returns true if ready otherwise, false
  29884. */
  29885. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29886. /**
  29887. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29888. * @param defines Defines of the material we want to update
  29889. * @param lightIndex Index of the light in the enabled light list of the material
  29890. */
  29891. prepareDefines(defines: any, lightIndex: number): void;
  29892. /**
  29893. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29894. * defined in the generator but impacting the effect).
  29895. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29896. * @param effect The effect we are binfing the information for
  29897. */
  29898. bindShadowLight(lightIndex: string, effect: Effect): void;
  29899. /**
  29900. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29901. * (eq to shadow prjection matrix * light transform matrix)
  29902. * @returns The transform matrix used to create the shadow map
  29903. */
  29904. getTransformMatrix(): Matrix;
  29905. /**
  29906. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29907. * Cube and 2D textures for instance.
  29908. */
  29909. recreateShadowMap(): void;
  29910. protected _disposeBlurPostProcesses(): void;
  29911. protected _disposeRTTandPostProcesses(): void;
  29912. /**
  29913. * Disposes the ShadowGenerator.
  29914. * Returns nothing.
  29915. */
  29916. dispose(): void;
  29917. /**
  29918. * Serializes the shadow generator setup to a json object.
  29919. * @returns The serialized JSON object
  29920. */
  29921. serialize(): any;
  29922. /**
  29923. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29924. * @param parsedShadowGenerator The JSON object to parse
  29925. * @param scene The scene to create the shadow map for
  29926. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29927. * @returns The parsed shadow generator
  29928. */
  29929. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29930. }
  29931. }
  29932. declare module BABYLON {
  29933. /**
  29934. * Options to be used when creating a shadow depth material
  29935. */
  29936. export interface IIOptionShadowDepthMaterial {
  29937. /** Variables in the vertex shader code that need to have their names remapped.
  29938. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29939. * "var_name" should be either: worldPos or vNormalW
  29940. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29941. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29942. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29943. */
  29944. remappedVariables?: string[];
  29945. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29946. standalone?: boolean;
  29947. }
  29948. /**
  29949. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29950. */
  29951. export class ShadowDepthWrapper {
  29952. private _scene;
  29953. private _options?;
  29954. private _baseMaterial;
  29955. private _onEffectCreatedObserver;
  29956. private _subMeshToEffect;
  29957. private _subMeshToDepthEffect;
  29958. private _meshes;
  29959. /** @hidden */
  29960. _matriceNames: any;
  29961. /** Gets the standalone status of the wrapper */
  29962. get standalone(): boolean;
  29963. /** Gets the base material the wrapper is built upon */
  29964. get baseMaterial(): Material;
  29965. /**
  29966. * Instantiate a new shadow depth wrapper.
  29967. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29968. * generate the shadow depth map. For more information, please refer to the documentation:
  29969. * https://doc.babylonjs.com/babylon101/shadows
  29970. * @param baseMaterial Material to wrap
  29971. * @param scene Define the scene the material belongs to
  29972. * @param options Options used to create the wrapper
  29973. */
  29974. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29975. /**
  29976. * Gets the effect to use to generate the depth map
  29977. * @param subMesh subMesh to get the effect for
  29978. * @param shadowGenerator shadow generator to get the effect for
  29979. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29980. */
  29981. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29982. /**
  29983. * Specifies that the submesh is ready to be used for depth rendering
  29984. * @param subMesh submesh to check
  29985. * @param defines the list of defines to take into account when checking the effect
  29986. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29987. * @param useInstances specifies that instances should be used
  29988. * @returns a boolean indicating that the submesh is ready or not
  29989. */
  29990. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29991. /**
  29992. * Disposes the resources
  29993. */
  29994. dispose(): void;
  29995. private _makeEffect;
  29996. }
  29997. }
  29998. declare module BABYLON {
  29999. /**
  30000. * Options for compiling materials.
  30001. */
  30002. export interface IMaterialCompilationOptions {
  30003. /**
  30004. * Defines whether clip planes are enabled.
  30005. */
  30006. clipPlane: boolean;
  30007. /**
  30008. * Defines whether instances are enabled.
  30009. */
  30010. useInstances: boolean;
  30011. }
  30012. /**
  30013. * Options passed when calling customShaderNameResolve
  30014. */
  30015. export interface ICustomShaderNameResolveOptions {
  30016. /**
  30017. * 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
  30018. */
  30019. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30020. }
  30021. /**
  30022. * Base class for the main features of a material in Babylon.js
  30023. */
  30024. export class Material implements IAnimatable {
  30025. /**
  30026. * Returns the triangle fill mode
  30027. */
  30028. static readonly TriangleFillMode: number;
  30029. /**
  30030. * Returns the wireframe mode
  30031. */
  30032. static readonly WireFrameFillMode: number;
  30033. /**
  30034. * Returns the point fill mode
  30035. */
  30036. static readonly PointFillMode: number;
  30037. /**
  30038. * Returns the point list draw mode
  30039. */
  30040. static readonly PointListDrawMode: number;
  30041. /**
  30042. * Returns the line list draw mode
  30043. */
  30044. static readonly LineListDrawMode: number;
  30045. /**
  30046. * Returns the line loop draw mode
  30047. */
  30048. static readonly LineLoopDrawMode: number;
  30049. /**
  30050. * Returns the line strip draw mode
  30051. */
  30052. static readonly LineStripDrawMode: number;
  30053. /**
  30054. * Returns the triangle strip draw mode
  30055. */
  30056. static readonly TriangleStripDrawMode: number;
  30057. /**
  30058. * Returns the triangle fan draw mode
  30059. */
  30060. static readonly TriangleFanDrawMode: number;
  30061. /**
  30062. * Stores the clock-wise side orientation
  30063. */
  30064. static readonly ClockWiseSideOrientation: number;
  30065. /**
  30066. * Stores the counter clock-wise side orientation
  30067. */
  30068. static readonly CounterClockWiseSideOrientation: number;
  30069. /**
  30070. * The dirty texture flag value
  30071. */
  30072. static readonly TextureDirtyFlag: number;
  30073. /**
  30074. * The dirty light flag value
  30075. */
  30076. static readonly LightDirtyFlag: number;
  30077. /**
  30078. * The dirty fresnel flag value
  30079. */
  30080. static readonly FresnelDirtyFlag: number;
  30081. /**
  30082. * The dirty attribute flag value
  30083. */
  30084. static readonly AttributesDirtyFlag: number;
  30085. /**
  30086. * The dirty misc flag value
  30087. */
  30088. static readonly MiscDirtyFlag: number;
  30089. /**
  30090. * The dirty prepass flag value
  30091. */
  30092. static readonly PrePassDirtyFlag: number;
  30093. /**
  30094. * The all dirty flag value
  30095. */
  30096. static readonly AllDirtyFlag: number;
  30097. /**
  30098. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30099. */
  30100. static readonly MATERIAL_OPAQUE: number;
  30101. /**
  30102. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30103. */
  30104. static readonly MATERIAL_ALPHATEST: number;
  30105. /**
  30106. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30107. */
  30108. static readonly MATERIAL_ALPHABLEND: number;
  30109. /**
  30110. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30111. * They are also discarded below the alpha cutoff threshold to improve performances.
  30112. */
  30113. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30114. /**
  30115. * The Whiteout method is used to blend normals.
  30116. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30117. */
  30118. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30119. /**
  30120. * The Reoriented Normal Mapping method is used to blend normals.
  30121. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30122. */
  30123. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30124. /**
  30125. * Custom callback helping to override the default shader used in the material.
  30126. */
  30127. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30128. /**
  30129. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30130. */
  30131. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30132. /**
  30133. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30134. * This means that the material can keep using a previous shader while a new one is being compiled.
  30135. * This is mostly used when shader parallel compilation is supported (true by default)
  30136. */
  30137. allowShaderHotSwapping: boolean;
  30138. /**
  30139. * The ID of the material
  30140. */
  30141. id: string;
  30142. /**
  30143. * Gets or sets the unique id of the material
  30144. */
  30145. uniqueId: number;
  30146. /**
  30147. * The name of the material
  30148. */
  30149. name: string;
  30150. /**
  30151. * Gets or sets user defined metadata
  30152. */
  30153. metadata: any;
  30154. /**
  30155. * For internal use only. Please do not use.
  30156. */
  30157. reservedDataStore: any;
  30158. /**
  30159. * Specifies if the ready state should be checked on each call
  30160. */
  30161. checkReadyOnEveryCall: boolean;
  30162. /**
  30163. * Specifies if the ready state should be checked once
  30164. */
  30165. checkReadyOnlyOnce: boolean;
  30166. /**
  30167. * The state of the material
  30168. */
  30169. state: string;
  30170. /**
  30171. * If the material can be rendered to several textures with MRT extension
  30172. */
  30173. get canRenderToMRT(): boolean;
  30174. /**
  30175. * The alpha value of the material
  30176. */
  30177. protected _alpha: number;
  30178. /**
  30179. * List of inspectable custom properties (used by the Inspector)
  30180. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30181. */
  30182. inspectableCustomProperties: IInspectable[];
  30183. /**
  30184. * Sets the alpha value of the material
  30185. */
  30186. set alpha(value: number);
  30187. /**
  30188. * Gets the alpha value of the material
  30189. */
  30190. get alpha(): number;
  30191. /**
  30192. * Specifies if back face culling is enabled
  30193. */
  30194. protected _backFaceCulling: boolean;
  30195. /**
  30196. * Sets the back-face culling state
  30197. */
  30198. set backFaceCulling(value: boolean);
  30199. /**
  30200. * Gets the back-face culling state
  30201. */
  30202. get backFaceCulling(): boolean;
  30203. /**
  30204. * Stores the value for side orientation
  30205. */
  30206. sideOrientation: number;
  30207. /**
  30208. * Callback triggered when the material is compiled
  30209. */
  30210. onCompiled: Nullable<(effect: Effect) => void>;
  30211. /**
  30212. * Callback triggered when an error occurs
  30213. */
  30214. onError: Nullable<(effect: Effect, errors: string) => void>;
  30215. /**
  30216. * Callback triggered to get the render target textures
  30217. */
  30218. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30219. /**
  30220. * Gets a boolean indicating that current material needs to register RTT
  30221. */
  30222. get hasRenderTargetTextures(): boolean;
  30223. /**
  30224. * Specifies if the material should be serialized
  30225. */
  30226. doNotSerialize: boolean;
  30227. /**
  30228. * @hidden
  30229. */
  30230. _storeEffectOnSubMeshes: boolean;
  30231. /**
  30232. * Stores the animations for the material
  30233. */
  30234. animations: Nullable<Array<Animation>>;
  30235. /**
  30236. * An event triggered when the material is disposed
  30237. */
  30238. onDisposeObservable: Observable<Material>;
  30239. /**
  30240. * An observer which watches for dispose events
  30241. */
  30242. private _onDisposeObserver;
  30243. private _onUnBindObservable;
  30244. /**
  30245. * Called during a dispose event
  30246. */
  30247. set onDispose(callback: () => void);
  30248. private _onBindObservable;
  30249. /**
  30250. * An event triggered when the material is bound
  30251. */
  30252. get onBindObservable(): Observable<AbstractMesh>;
  30253. /**
  30254. * An observer which watches for bind events
  30255. */
  30256. private _onBindObserver;
  30257. /**
  30258. * Called during a bind event
  30259. */
  30260. set onBind(callback: (Mesh: AbstractMesh) => void);
  30261. /**
  30262. * An event triggered when the material is unbound
  30263. */
  30264. get onUnBindObservable(): Observable<Material>;
  30265. protected _onEffectCreatedObservable: Nullable<Observable<{
  30266. effect: Effect;
  30267. subMesh: Nullable<SubMesh>;
  30268. }>>;
  30269. /**
  30270. * An event triggered when the effect is (re)created
  30271. */
  30272. get onEffectCreatedObservable(): Observable<{
  30273. effect: Effect;
  30274. subMesh: Nullable<SubMesh>;
  30275. }>;
  30276. /**
  30277. * Stores the value of the alpha mode
  30278. */
  30279. private _alphaMode;
  30280. /**
  30281. * Sets the value of the alpha mode.
  30282. *
  30283. * | Value | Type | Description |
  30284. * | --- | --- | --- |
  30285. * | 0 | ALPHA_DISABLE | |
  30286. * | 1 | ALPHA_ADD | |
  30287. * | 2 | ALPHA_COMBINE | |
  30288. * | 3 | ALPHA_SUBTRACT | |
  30289. * | 4 | ALPHA_MULTIPLY | |
  30290. * | 5 | ALPHA_MAXIMIZED | |
  30291. * | 6 | ALPHA_ONEONE | |
  30292. * | 7 | ALPHA_PREMULTIPLIED | |
  30293. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30294. * | 9 | ALPHA_INTERPOLATE | |
  30295. * | 10 | ALPHA_SCREENMODE | |
  30296. *
  30297. */
  30298. set alphaMode(value: number);
  30299. /**
  30300. * Gets the value of the alpha mode
  30301. */
  30302. get alphaMode(): number;
  30303. /**
  30304. * Stores the state of the need depth pre-pass value
  30305. */
  30306. private _needDepthPrePass;
  30307. /**
  30308. * Sets the need depth pre-pass value
  30309. */
  30310. set needDepthPrePass(value: boolean);
  30311. /**
  30312. * Gets the depth pre-pass value
  30313. */
  30314. get needDepthPrePass(): boolean;
  30315. /**
  30316. * Specifies if depth writing should be disabled
  30317. */
  30318. disableDepthWrite: boolean;
  30319. /**
  30320. * Specifies if color writing should be disabled
  30321. */
  30322. disableColorWrite: boolean;
  30323. /**
  30324. * Specifies if depth writing should be forced
  30325. */
  30326. forceDepthWrite: boolean;
  30327. /**
  30328. * Specifies the depth function that should be used. 0 means the default engine function
  30329. */
  30330. depthFunction: number;
  30331. /**
  30332. * Specifies if there should be a separate pass for culling
  30333. */
  30334. separateCullingPass: boolean;
  30335. /**
  30336. * Stores the state specifing if fog should be enabled
  30337. */
  30338. private _fogEnabled;
  30339. /**
  30340. * Sets the state for enabling fog
  30341. */
  30342. set fogEnabled(value: boolean);
  30343. /**
  30344. * Gets the value of the fog enabled state
  30345. */
  30346. get fogEnabled(): boolean;
  30347. /**
  30348. * Stores the size of points
  30349. */
  30350. pointSize: number;
  30351. /**
  30352. * Stores the z offset value
  30353. */
  30354. zOffset: number;
  30355. get wireframe(): boolean;
  30356. /**
  30357. * Sets the state of wireframe mode
  30358. */
  30359. set wireframe(value: boolean);
  30360. /**
  30361. * Gets the value specifying if point clouds are enabled
  30362. */
  30363. get pointsCloud(): boolean;
  30364. /**
  30365. * Sets the state of point cloud mode
  30366. */
  30367. set pointsCloud(value: boolean);
  30368. /**
  30369. * Gets the material fill mode
  30370. */
  30371. get fillMode(): number;
  30372. /**
  30373. * Sets the material fill mode
  30374. */
  30375. set fillMode(value: number);
  30376. /**
  30377. * @hidden
  30378. * Stores the effects for the material
  30379. */
  30380. _effect: Nullable<Effect>;
  30381. /**
  30382. * Specifies if uniform buffers should be used
  30383. */
  30384. private _useUBO;
  30385. /**
  30386. * Stores a reference to the scene
  30387. */
  30388. private _scene;
  30389. private _needToBindSceneUbo;
  30390. /**
  30391. * Stores the fill mode state
  30392. */
  30393. private _fillMode;
  30394. /**
  30395. * Specifies if the depth write state should be cached
  30396. */
  30397. private _cachedDepthWriteState;
  30398. /**
  30399. * Specifies if the color write state should be cached
  30400. */
  30401. private _cachedColorWriteState;
  30402. /**
  30403. * Specifies if the depth function state should be cached
  30404. */
  30405. private _cachedDepthFunctionState;
  30406. /**
  30407. * Stores the uniform buffer
  30408. */
  30409. protected _uniformBuffer: UniformBuffer;
  30410. /** @hidden */
  30411. _indexInSceneMaterialArray: number;
  30412. /** @hidden */
  30413. meshMap: Nullable<{
  30414. [id: string]: AbstractMesh | undefined;
  30415. }>;
  30416. /**
  30417. * Creates a material instance
  30418. * @param name defines the name of the material
  30419. * @param scene defines the scene to reference
  30420. * @param doNotAdd specifies if the material should be added to the scene
  30421. */
  30422. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30423. /**
  30424. * Returns a string representation of the current material
  30425. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30426. * @returns a string with material information
  30427. */
  30428. toString(fullDetails?: boolean): string;
  30429. /**
  30430. * Gets the class name of the material
  30431. * @returns a string with the class name of the material
  30432. */
  30433. getClassName(): string;
  30434. /**
  30435. * Specifies if updates for the material been locked
  30436. */
  30437. get isFrozen(): boolean;
  30438. /**
  30439. * Locks updates for the material
  30440. */
  30441. freeze(): void;
  30442. /**
  30443. * Unlocks updates for the material
  30444. */
  30445. unfreeze(): void;
  30446. /**
  30447. * Specifies if the material is ready to be used
  30448. * @param mesh defines the mesh to check
  30449. * @param useInstances specifies if instances should be used
  30450. * @returns a boolean indicating if the material is ready to be used
  30451. */
  30452. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30453. /**
  30454. * Specifies that the submesh is ready to be used
  30455. * @param mesh defines the mesh to check
  30456. * @param subMesh defines which submesh to check
  30457. * @param useInstances specifies that instances should be used
  30458. * @returns a boolean indicating that the submesh is ready or not
  30459. */
  30460. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30461. /**
  30462. * Returns the material effect
  30463. * @returns the effect associated with the material
  30464. */
  30465. getEffect(): Nullable<Effect>;
  30466. /**
  30467. * Returns the current scene
  30468. * @returns a Scene
  30469. */
  30470. getScene(): Scene;
  30471. /**
  30472. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30473. */
  30474. protected _forceAlphaTest: boolean;
  30475. /**
  30476. * The transparency mode of the material.
  30477. */
  30478. protected _transparencyMode: Nullable<number>;
  30479. /**
  30480. * Gets the current transparency mode.
  30481. */
  30482. get transparencyMode(): Nullable<number>;
  30483. /**
  30484. * Sets the transparency mode of the material.
  30485. *
  30486. * | Value | Type | Description |
  30487. * | ----- | ----------------------------------- | ----------- |
  30488. * | 0 | OPAQUE | |
  30489. * | 1 | ALPHATEST | |
  30490. * | 2 | ALPHABLEND | |
  30491. * | 3 | ALPHATESTANDBLEND | |
  30492. *
  30493. */
  30494. set transparencyMode(value: Nullable<number>);
  30495. /**
  30496. * Returns true if alpha blending should be disabled.
  30497. */
  30498. protected get _disableAlphaBlending(): boolean;
  30499. /**
  30500. * Specifies whether or not this material should be rendered in alpha blend mode.
  30501. * @returns a boolean specifying if alpha blending is needed
  30502. */
  30503. needAlphaBlending(): boolean;
  30504. /**
  30505. * Specifies if the mesh will require alpha blending
  30506. * @param mesh defines the mesh to check
  30507. * @returns a boolean specifying if alpha blending is needed for the mesh
  30508. */
  30509. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30510. /**
  30511. * Specifies whether or not this material should be rendered in alpha test mode.
  30512. * @returns a boolean specifying if an alpha test is needed.
  30513. */
  30514. needAlphaTesting(): boolean;
  30515. /**
  30516. * Specifies if material alpha testing should be turned on for the mesh
  30517. * @param mesh defines the mesh to check
  30518. */
  30519. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30520. /**
  30521. * Gets the texture used for the alpha test
  30522. * @returns the texture to use for alpha testing
  30523. */
  30524. getAlphaTestTexture(): Nullable<BaseTexture>;
  30525. /**
  30526. * Marks the material to indicate that it needs to be re-calculated
  30527. */
  30528. markDirty(): void;
  30529. /** @hidden */
  30530. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30531. /**
  30532. * Binds the material to the mesh
  30533. * @param world defines the world transformation matrix
  30534. * @param mesh defines the mesh to bind the material to
  30535. */
  30536. bind(world: Matrix, mesh?: Mesh): void;
  30537. /**
  30538. * Binds the submesh to the material
  30539. * @param world defines the world transformation matrix
  30540. * @param mesh defines the mesh containing the submesh
  30541. * @param subMesh defines the submesh to bind the material to
  30542. */
  30543. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30544. /**
  30545. * Binds the world matrix to the material
  30546. * @param world defines the world transformation matrix
  30547. */
  30548. bindOnlyWorldMatrix(world: Matrix): void;
  30549. /**
  30550. * Update the scene ubo before it can be used in rendering processing
  30551. * @param scene the scene to retrieve the ubo from
  30552. * @returns the scene UniformBuffer
  30553. */
  30554. finalizeSceneUbo(scene: Scene): UniformBuffer;
  30555. /**
  30556. * Binds the scene's uniform buffer to the effect.
  30557. * @param effect defines the effect to bind to the scene uniform buffer
  30558. * @param sceneUbo defines the uniform buffer storing scene data
  30559. */
  30560. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30561. /**
  30562. * Binds the view matrix to the effect
  30563. * @param effect defines the effect to bind the view matrix to
  30564. */
  30565. bindView(effect: Effect): void;
  30566. /**
  30567. * Binds the view projection and projection matrices to the effect
  30568. * @param effect defines the effect to bind the view projection and projection matrices to
  30569. */
  30570. bindViewProjection(effect: Effect): void;
  30571. /**
  30572. * Binds the view matrix to the effect
  30573. * @param effect defines the effect to bind the view matrix to
  30574. * @param variableName name of the shader variable that will hold the eye position
  30575. */
  30576. bindEyePosition(effect: Effect, variableName?: string): void;
  30577. /**
  30578. * Processes to execute after binding the material to a mesh
  30579. * @param mesh defines the rendered mesh
  30580. */
  30581. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30582. /**
  30583. * Unbinds the material from the mesh
  30584. */
  30585. unbind(): void;
  30586. /**
  30587. * Gets the active textures from the material
  30588. * @returns an array of textures
  30589. */
  30590. getActiveTextures(): BaseTexture[];
  30591. /**
  30592. * Specifies if the material uses a texture
  30593. * @param texture defines the texture to check against the material
  30594. * @returns a boolean specifying if the material uses the texture
  30595. */
  30596. hasTexture(texture: BaseTexture): boolean;
  30597. /**
  30598. * Makes a duplicate of the material, and gives it a new name
  30599. * @param name defines the new name for the duplicated material
  30600. * @returns the cloned material
  30601. */
  30602. clone(name: string): Nullable<Material>;
  30603. /**
  30604. * Gets the meshes bound to the material
  30605. * @returns an array of meshes bound to the material
  30606. */
  30607. getBindedMeshes(): AbstractMesh[];
  30608. /**
  30609. * Force shader compilation
  30610. * @param mesh defines the mesh associated with this material
  30611. * @param onCompiled defines a function to execute once the material is compiled
  30612. * @param options defines the options to configure the compilation
  30613. * @param onError defines a function to execute if the material fails compiling
  30614. */
  30615. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30616. /**
  30617. * Force shader compilation
  30618. * @param mesh defines the mesh that will use this material
  30619. * @param options defines additional options for compiling the shaders
  30620. * @returns a promise that resolves when the compilation completes
  30621. */
  30622. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30623. private static readonly _AllDirtyCallBack;
  30624. private static readonly _ImageProcessingDirtyCallBack;
  30625. private static readonly _TextureDirtyCallBack;
  30626. private static readonly _FresnelDirtyCallBack;
  30627. private static readonly _MiscDirtyCallBack;
  30628. private static readonly _PrePassDirtyCallBack;
  30629. private static readonly _LightsDirtyCallBack;
  30630. private static readonly _AttributeDirtyCallBack;
  30631. private static _FresnelAndMiscDirtyCallBack;
  30632. private static _TextureAndMiscDirtyCallBack;
  30633. private static readonly _DirtyCallbackArray;
  30634. private static readonly _RunDirtyCallBacks;
  30635. /**
  30636. * Marks a define in the material to indicate that it needs to be re-computed
  30637. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30638. */
  30639. markAsDirty(flag: number): void;
  30640. /**
  30641. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30642. * @param func defines a function which checks material defines against the submeshes
  30643. */
  30644. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30645. /**
  30646. * Indicates that the scene should check if the rendering now needs a prepass
  30647. */
  30648. protected _markScenePrePassDirty(): void;
  30649. /**
  30650. * Indicates that we need to re-calculated for all submeshes
  30651. */
  30652. protected _markAllSubMeshesAsAllDirty(): void;
  30653. /**
  30654. * Indicates that image processing needs to be re-calculated for all submeshes
  30655. */
  30656. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30657. /**
  30658. * Indicates that textures need to be re-calculated for all submeshes
  30659. */
  30660. protected _markAllSubMeshesAsTexturesDirty(): void;
  30661. /**
  30662. * Indicates that fresnel needs to be re-calculated for all submeshes
  30663. */
  30664. protected _markAllSubMeshesAsFresnelDirty(): void;
  30665. /**
  30666. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30667. */
  30668. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30669. /**
  30670. * Indicates that lights need to be re-calculated for all submeshes
  30671. */
  30672. protected _markAllSubMeshesAsLightsDirty(): void;
  30673. /**
  30674. * Indicates that attributes need to be re-calculated for all submeshes
  30675. */
  30676. protected _markAllSubMeshesAsAttributesDirty(): void;
  30677. /**
  30678. * Indicates that misc needs to be re-calculated for all submeshes
  30679. */
  30680. protected _markAllSubMeshesAsMiscDirty(): void;
  30681. /**
  30682. * Indicates that prepass needs to be re-calculated for all submeshes
  30683. */
  30684. protected _markAllSubMeshesAsPrePassDirty(): void;
  30685. /**
  30686. * Indicates that textures and misc need to be re-calculated for all submeshes
  30687. */
  30688. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30689. /**
  30690. * Sets the required values to the prepass renderer.
  30691. * @param prePassRenderer defines the prepass renderer to setup.
  30692. * @returns true if the pre pass is needed.
  30693. */
  30694. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30695. /**
  30696. * Disposes the material
  30697. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30698. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30699. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30700. */
  30701. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30702. /** @hidden */
  30703. private releaseVertexArrayObject;
  30704. /**
  30705. * Serializes this material
  30706. * @returns the serialized material object
  30707. */
  30708. serialize(): any;
  30709. /**
  30710. * Creates a material from parsed material data
  30711. * @param parsedMaterial defines parsed material data
  30712. * @param scene defines the hosting scene
  30713. * @param rootUrl defines the root URL to use to load textures
  30714. * @returns a new material
  30715. */
  30716. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30717. }
  30718. }
  30719. declare module BABYLON {
  30720. /**
  30721. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30722. * separate meshes. This can be use to improve performances.
  30723. * @see https://doc.babylonjs.com/how_to/multi_materials
  30724. */
  30725. export class MultiMaterial extends Material {
  30726. private _subMaterials;
  30727. /**
  30728. * Gets or Sets the list of Materials used within the multi material.
  30729. * They need to be ordered according to the submeshes order in the associated mesh
  30730. */
  30731. get subMaterials(): Nullable<Material>[];
  30732. set subMaterials(value: Nullable<Material>[]);
  30733. /**
  30734. * Function used to align with Node.getChildren()
  30735. * @returns the list of Materials used within the multi material
  30736. */
  30737. getChildren(): Nullable<Material>[];
  30738. /**
  30739. * Instantiates a new Multi Material
  30740. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30741. * separate meshes. This can be use to improve performances.
  30742. * @see https://doc.babylonjs.com/how_to/multi_materials
  30743. * @param name Define the name in the scene
  30744. * @param scene Define the scene the material belongs to
  30745. */
  30746. constructor(name: string, scene: Scene);
  30747. private _hookArray;
  30748. /**
  30749. * Get one of the submaterial by its index in the submaterials array
  30750. * @param index The index to look the sub material at
  30751. * @returns The Material if the index has been defined
  30752. */
  30753. getSubMaterial(index: number): Nullable<Material>;
  30754. /**
  30755. * Get the list of active textures for the whole sub materials list.
  30756. * @returns All the textures that will be used during the rendering
  30757. */
  30758. getActiveTextures(): BaseTexture[];
  30759. /**
  30760. * Specifies if any sub-materials of this multi-material use a given texture.
  30761. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30762. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30763. */
  30764. hasTexture(texture: BaseTexture): boolean;
  30765. /**
  30766. * Gets the current class name of the material e.g. "MultiMaterial"
  30767. * Mainly use in serialization.
  30768. * @returns the class name
  30769. */
  30770. getClassName(): string;
  30771. /**
  30772. * Checks if the material is ready to render the requested sub mesh
  30773. * @param mesh Define the mesh the submesh belongs to
  30774. * @param subMesh Define the sub mesh to look readyness for
  30775. * @param useInstances Define whether or not the material is used with instances
  30776. * @returns true if ready, otherwise false
  30777. */
  30778. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30779. /**
  30780. * Clones the current material and its related sub materials
  30781. * @param name Define the name of the newly cloned material
  30782. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30783. * @returns the cloned material
  30784. */
  30785. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30786. /**
  30787. * Serializes the materials into a JSON representation.
  30788. * @returns the JSON representation
  30789. */
  30790. serialize(): any;
  30791. /**
  30792. * Dispose the material and release its associated resources
  30793. * @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)
  30794. * @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)
  30795. * @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)
  30796. */
  30797. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30798. /**
  30799. * Creates a MultiMaterial from parsed MultiMaterial data.
  30800. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30801. * @param scene defines the hosting scene
  30802. * @returns a new MultiMaterial
  30803. */
  30804. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30805. }
  30806. }
  30807. declare module BABYLON {
  30808. /** @hidden */
  30809. export interface ICustomEffect {
  30810. effect: Effect;
  30811. defines: string;
  30812. }
  30813. /**
  30814. * Defines a subdivision inside a mesh
  30815. */
  30816. export class SubMesh implements ICullable {
  30817. /** the material index to use */
  30818. materialIndex: number;
  30819. /** vertex index start */
  30820. verticesStart: number;
  30821. /** vertices count */
  30822. verticesCount: number;
  30823. /** index start */
  30824. indexStart: number;
  30825. /** indices count */
  30826. indexCount: number;
  30827. /** @hidden */
  30828. _materialDefines: Nullable<MaterialDefines>;
  30829. /** @hidden */
  30830. _materialEffect: Nullable<Effect>;
  30831. /** @hidden */
  30832. _effectOverride: Nullable<Effect>;
  30833. private _customEffects;
  30834. /**
  30835. * Gets material defines used by the effect associated to the sub mesh
  30836. */
  30837. get materialDefines(): Nullable<MaterialDefines>;
  30838. /**
  30839. * Sets material defines used by the effect associated to the sub mesh
  30840. */
  30841. set materialDefines(defines: Nullable<MaterialDefines>);
  30842. /** @hidden */
  30843. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  30844. /** @hidden */
  30845. _removeCustomEffect(name: string): void;
  30846. /**
  30847. * Gets associated effect
  30848. */
  30849. get effect(): Nullable<Effect>;
  30850. /**
  30851. * Sets associated effect (effect used to render this submesh)
  30852. * @param effect defines the effect to associate with
  30853. * @param defines defines the set of defines used to compile this effect
  30854. */
  30855. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30856. /** @hidden */
  30857. _linesIndexCount: number;
  30858. private _mesh;
  30859. private _renderingMesh;
  30860. private _boundingInfo;
  30861. private _linesIndexBuffer;
  30862. /** @hidden */
  30863. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30864. /** @hidden */
  30865. _trianglePlanes: Plane[];
  30866. /** @hidden */
  30867. _lastColliderTransformMatrix: Nullable<Matrix>;
  30868. /** @hidden */
  30869. _renderId: number;
  30870. /** @hidden */
  30871. _alphaIndex: number;
  30872. /** @hidden */
  30873. _distanceToCamera: number;
  30874. /** @hidden */
  30875. _id: number;
  30876. private _currentMaterial;
  30877. /**
  30878. * Add a new submesh to a mesh
  30879. * @param materialIndex defines the material index to use
  30880. * @param verticesStart defines vertex index start
  30881. * @param verticesCount defines vertices count
  30882. * @param indexStart defines index start
  30883. * @param indexCount defines indices count
  30884. * @param mesh defines the parent mesh
  30885. * @param renderingMesh defines an optional rendering mesh
  30886. * @param createBoundingBox defines if bounding box should be created for this submesh
  30887. * @returns the new submesh
  30888. */
  30889. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30890. /**
  30891. * Creates a new submesh
  30892. * @param materialIndex defines the material index to use
  30893. * @param verticesStart defines vertex index start
  30894. * @param verticesCount defines vertices count
  30895. * @param indexStart defines index start
  30896. * @param indexCount defines indices count
  30897. * @param mesh defines the parent mesh
  30898. * @param renderingMesh defines an optional rendering mesh
  30899. * @param createBoundingBox defines if bounding box should be created for this submesh
  30900. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30901. */
  30902. constructor(
  30903. /** the material index to use */
  30904. materialIndex: number,
  30905. /** vertex index start */
  30906. verticesStart: number,
  30907. /** vertices count */
  30908. verticesCount: number,
  30909. /** index start */
  30910. indexStart: number,
  30911. /** indices count */
  30912. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30913. /**
  30914. * Returns true if this submesh covers the entire parent mesh
  30915. * @ignorenaming
  30916. */
  30917. get IsGlobal(): boolean;
  30918. /**
  30919. * Returns the submesh BoudingInfo object
  30920. * @returns current bounding info (or mesh's one if the submesh is global)
  30921. */
  30922. getBoundingInfo(): BoundingInfo;
  30923. /**
  30924. * Sets the submesh BoundingInfo
  30925. * @param boundingInfo defines the new bounding info to use
  30926. * @returns the SubMesh
  30927. */
  30928. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30929. /**
  30930. * Returns the mesh of the current submesh
  30931. * @return the parent mesh
  30932. */
  30933. getMesh(): AbstractMesh;
  30934. /**
  30935. * Returns the rendering mesh of the submesh
  30936. * @returns the rendering mesh (could be different from parent mesh)
  30937. */
  30938. getRenderingMesh(): Mesh;
  30939. /**
  30940. * Returns the replacement mesh of the submesh
  30941. * @returns the replacement mesh (could be different from parent mesh)
  30942. */
  30943. getReplacementMesh(): Nullable<AbstractMesh>;
  30944. /**
  30945. * Returns the effective mesh of the submesh
  30946. * @returns the effective mesh (could be different from parent mesh)
  30947. */
  30948. getEffectiveMesh(): AbstractMesh;
  30949. /**
  30950. * Returns the submesh material
  30951. * @returns null or the current material
  30952. */
  30953. getMaterial(): Nullable<Material>;
  30954. private _IsMultiMaterial;
  30955. /**
  30956. * Sets a new updated BoundingInfo object to the submesh
  30957. * @param data defines an optional position array to use to determine the bounding info
  30958. * @returns the SubMesh
  30959. */
  30960. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30961. /** @hidden */
  30962. _checkCollision(collider: Collider): boolean;
  30963. /**
  30964. * Updates the submesh BoundingInfo
  30965. * @param world defines the world matrix to use to update the bounding info
  30966. * @returns the submesh
  30967. */
  30968. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30969. /**
  30970. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30971. * @param frustumPlanes defines the frustum planes
  30972. * @returns true if the submesh is intersecting with the frustum
  30973. */
  30974. isInFrustum(frustumPlanes: Plane[]): boolean;
  30975. /**
  30976. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30977. * @param frustumPlanes defines the frustum planes
  30978. * @returns true if the submesh is inside the frustum
  30979. */
  30980. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30981. /**
  30982. * Renders the submesh
  30983. * @param enableAlphaMode defines if alpha needs to be used
  30984. * @returns the submesh
  30985. */
  30986. render(enableAlphaMode: boolean): SubMesh;
  30987. /**
  30988. * @hidden
  30989. */
  30990. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30991. /**
  30992. * Checks if the submesh intersects with a ray
  30993. * @param ray defines the ray to test
  30994. * @returns true is the passed ray intersects the submesh bounding box
  30995. */
  30996. canIntersects(ray: Ray): boolean;
  30997. /**
  30998. * Intersects current submesh with a ray
  30999. * @param ray defines the ray to test
  31000. * @param positions defines mesh's positions array
  31001. * @param indices defines mesh's indices array
  31002. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31003. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31004. * @returns intersection info or null if no intersection
  31005. */
  31006. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31007. /** @hidden */
  31008. private _intersectLines;
  31009. /** @hidden */
  31010. private _intersectUnIndexedLines;
  31011. /** @hidden */
  31012. private _intersectTriangles;
  31013. /** @hidden */
  31014. private _intersectUnIndexedTriangles;
  31015. /** @hidden */
  31016. _rebuild(): void;
  31017. /**
  31018. * Creates a new submesh from the passed mesh
  31019. * @param newMesh defines the new hosting mesh
  31020. * @param newRenderingMesh defines an optional rendering mesh
  31021. * @returns the new submesh
  31022. */
  31023. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31024. /**
  31025. * Release associated resources
  31026. */
  31027. dispose(): void;
  31028. /**
  31029. * Gets the class name
  31030. * @returns the string "SubMesh".
  31031. */
  31032. getClassName(): string;
  31033. /**
  31034. * Creates a new submesh from indices data
  31035. * @param materialIndex the index of the main mesh material
  31036. * @param startIndex the index where to start the copy in the mesh indices array
  31037. * @param indexCount the number of indices to copy then from the startIndex
  31038. * @param mesh the main mesh to create the submesh from
  31039. * @param renderingMesh the optional rendering mesh
  31040. * @returns a new submesh
  31041. */
  31042. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31043. }
  31044. }
  31045. declare module BABYLON {
  31046. /**
  31047. * Class used to represent data loading progression
  31048. */
  31049. export class SceneLoaderFlags {
  31050. private static _ForceFullSceneLoadingForIncremental;
  31051. private static _ShowLoadingScreen;
  31052. private static _CleanBoneMatrixWeights;
  31053. private static _loggingLevel;
  31054. /**
  31055. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31056. */
  31057. static get ForceFullSceneLoadingForIncremental(): boolean;
  31058. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31059. /**
  31060. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31061. */
  31062. static get ShowLoadingScreen(): boolean;
  31063. static set ShowLoadingScreen(value: boolean);
  31064. /**
  31065. * Defines the current logging level (while loading the scene)
  31066. * @ignorenaming
  31067. */
  31068. static get loggingLevel(): number;
  31069. static set loggingLevel(value: number);
  31070. /**
  31071. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31072. */
  31073. static get CleanBoneMatrixWeights(): boolean;
  31074. static set CleanBoneMatrixWeights(value: boolean);
  31075. }
  31076. }
  31077. declare module BABYLON {
  31078. /**
  31079. * Class used to store geometry data (vertex buffers + index buffer)
  31080. */
  31081. export class Geometry implements IGetSetVerticesData {
  31082. /**
  31083. * Gets or sets the ID of the geometry
  31084. */
  31085. id: string;
  31086. /**
  31087. * Gets or sets the unique ID of the geometry
  31088. */
  31089. uniqueId: number;
  31090. /**
  31091. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31092. */
  31093. delayLoadState: number;
  31094. /**
  31095. * Gets the file containing the data to load when running in delay load state
  31096. */
  31097. delayLoadingFile: Nullable<string>;
  31098. /**
  31099. * Callback called when the geometry is updated
  31100. */
  31101. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31102. private _scene;
  31103. private _engine;
  31104. private _meshes;
  31105. private _totalVertices;
  31106. /** @hidden */
  31107. _indices: IndicesArray;
  31108. /** @hidden */
  31109. _vertexBuffers: {
  31110. [key: string]: VertexBuffer;
  31111. };
  31112. private _isDisposed;
  31113. private _extend;
  31114. private _boundingBias;
  31115. /** @hidden */
  31116. _delayInfo: Array<string>;
  31117. private _indexBuffer;
  31118. private _indexBufferIsUpdatable;
  31119. /** @hidden */
  31120. _boundingInfo: Nullable<BoundingInfo>;
  31121. /** @hidden */
  31122. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31123. /** @hidden */
  31124. _softwareSkinningFrameId: number;
  31125. private _vertexArrayObjects;
  31126. private _updatable;
  31127. /** @hidden */
  31128. _positions: Nullable<Vector3[]>;
  31129. private _positionsCache;
  31130. /**
  31131. * 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
  31132. */
  31133. get boundingBias(): Vector2;
  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. set boundingBias(value: Vector2);
  31138. /**
  31139. * Static function used to attach a new empty geometry to a mesh
  31140. * @param mesh defines the mesh to attach the geometry to
  31141. * @returns the new Geometry
  31142. */
  31143. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31144. /** Get the list of meshes using this geometry */
  31145. get meshes(): Mesh[];
  31146. /**
  31147. * 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
  31148. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31149. */
  31150. useBoundingInfoFromGeometry: boolean;
  31151. /**
  31152. * Creates a new geometry
  31153. * @param id defines the unique ID
  31154. * @param scene defines the hosting scene
  31155. * @param vertexData defines the VertexData used to get geometry data
  31156. * @param updatable defines if geometry must be updatable (false by default)
  31157. * @param mesh defines the mesh that will be associated with the geometry
  31158. */
  31159. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31160. /**
  31161. * Gets the current extend of the geometry
  31162. */
  31163. get extend(): {
  31164. minimum: Vector3;
  31165. maximum: Vector3;
  31166. };
  31167. /**
  31168. * Gets the hosting scene
  31169. * @returns the hosting Scene
  31170. */
  31171. getScene(): Scene;
  31172. /**
  31173. * Gets the hosting engine
  31174. * @returns the hosting Engine
  31175. */
  31176. getEngine(): Engine;
  31177. /**
  31178. * Defines if the geometry is ready to use
  31179. * @returns true if the geometry is ready to be used
  31180. */
  31181. isReady(): boolean;
  31182. /**
  31183. * Gets a value indicating that the geometry should not be serialized
  31184. */
  31185. get doNotSerialize(): boolean;
  31186. /** @hidden */
  31187. _rebuild(): void;
  31188. /**
  31189. * Affects all geometry data in one call
  31190. * @param vertexData defines the geometry data
  31191. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31192. */
  31193. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31194. /**
  31195. * Set specific vertex data
  31196. * @param kind defines the data kind (Position, normal, etc...)
  31197. * @param data defines the vertex data to use
  31198. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31199. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31200. */
  31201. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31202. /**
  31203. * Removes a specific vertex data
  31204. * @param kind defines the data kind (Position, normal, etc...)
  31205. */
  31206. removeVerticesData(kind: string): void;
  31207. /**
  31208. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31209. * @param buffer defines the vertex buffer to use
  31210. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31211. */
  31212. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31213. /**
  31214. * Update a specific vertex buffer
  31215. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31216. * It will do nothing if the buffer is not updatable
  31217. * @param kind defines the data kind (Position, normal, etc...)
  31218. * @param data defines the data to use
  31219. * @param offset defines the offset in the target buffer where to store the data
  31220. * @param useBytes set to true if the offset is in bytes
  31221. */
  31222. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31223. /**
  31224. * Update a specific vertex buffer
  31225. * This function will create a new buffer if the current one is not updatable
  31226. * @param kind defines the data kind (Position, normal, etc...)
  31227. * @param data defines the data to use
  31228. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31229. */
  31230. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31231. private _updateBoundingInfo;
  31232. /** @hidden */
  31233. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31234. /**
  31235. * Gets total number of vertices
  31236. * @returns the total number of vertices
  31237. */
  31238. getTotalVertices(): number;
  31239. /**
  31240. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31241. * @param kind defines the data kind (Position, normal, etc...)
  31242. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31243. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31244. * @returns a float array containing vertex data
  31245. */
  31246. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31247. /**
  31248. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31249. * @param kind defines the data kind (Position, normal, etc...)
  31250. * @returns true if the vertex buffer with the specified kind is updatable
  31251. */
  31252. isVertexBufferUpdatable(kind: string): boolean;
  31253. /**
  31254. * Gets a specific vertex buffer
  31255. * @param kind defines the data kind (Position, normal, etc...)
  31256. * @returns a VertexBuffer
  31257. */
  31258. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31259. /**
  31260. * Returns all vertex buffers
  31261. * @return an object holding all vertex buffers indexed by kind
  31262. */
  31263. getVertexBuffers(): Nullable<{
  31264. [key: string]: VertexBuffer;
  31265. }>;
  31266. /**
  31267. * Gets a boolean indicating if specific vertex buffer is present
  31268. * @param kind defines the data kind (Position, normal, etc...)
  31269. * @returns true if data is present
  31270. */
  31271. isVerticesDataPresent(kind: string): boolean;
  31272. /**
  31273. * Gets a list of all attached data kinds (Position, normal, etc...)
  31274. * @returns a list of string containing all kinds
  31275. */
  31276. getVerticesDataKinds(): string[];
  31277. /**
  31278. * Update index buffer
  31279. * @param indices defines the indices to store in the index buffer
  31280. * @param offset defines the offset in the target buffer where to store the data
  31281. * @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)
  31282. */
  31283. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31284. /**
  31285. * Creates a new index buffer
  31286. * @param indices defines the indices to store in the index buffer
  31287. * @param totalVertices defines the total number of vertices (could be null)
  31288. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31289. */
  31290. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31291. /**
  31292. * Return the total number of indices
  31293. * @returns the total number of indices
  31294. */
  31295. getTotalIndices(): number;
  31296. /**
  31297. * Gets the index buffer array
  31298. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31299. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31300. * @returns the index buffer array
  31301. */
  31302. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31303. /**
  31304. * Gets the index buffer
  31305. * @return the index buffer
  31306. */
  31307. getIndexBuffer(): Nullable<DataBuffer>;
  31308. /** @hidden */
  31309. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31310. /**
  31311. * Release the associated resources for a specific mesh
  31312. * @param mesh defines the source mesh
  31313. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31314. */
  31315. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31316. /**
  31317. * Apply current geometry to a given mesh
  31318. * @param mesh defines the mesh to apply geometry to
  31319. */
  31320. applyToMesh(mesh: Mesh): void;
  31321. private _updateExtend;
  31322. private _applyToMesh;
  31323. private notifyUpdate;
  31324. /**
  31325. * Load the geometry if it was flagged as delay loaded
  31326. * @param scene defines the hosting scene
  31327. * @param onLoaded defines a callback called when the geometry is loaded
  31328. */
  31329. load(scene: Scene, onLoaded?: () => void): void;
  31330. private _queueLoad;
  31331. /**
  31332. * Invert the geometry to move from a right handed system to a left handed one.
  31333. */
  31334. toLeftHanded(): void;
  31335. /** @hidden */
  31336. _resetPointsArrayCache(): void;
  31337. /** @hidden */
  31338. _generatePointsArray(): boolean;
  31339. /**
  31340. * Gets a value indicating if the geometry is disposed
  31341. * @returns true if the geometry was disposed
  31342. */
  31343. isDisposed(): boolean;
  31344. private _disposeVertexArrayObjects;
  31345. /**
  31346. * Free all associated resources
  31347. */
  31348. dispose(): void;
  31349. /**
  31350. * Clone the current geometry into a new geometry
  31351. * @param id defines the unique ID of the new geometry
  31352. * @returns a new geometry object
  31353. */
  31354. copy(id: string): Geometry;
  31355. /**
  31356. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31357. * @return a JSON representation of the current geometry data (without the vertices data)
  31358. */
  31359. serialize(): any;
  31360. private toNumberArray;
  31361. /**
  31362. * Serialize all vertices data into a JSON oject
  31363. * @returns a JSON representation of the current geometry data
  31364. */
  31365. serializeVerticeData(): any;
  31366. /**
  31367. * Extracts a clone of a mesh geometry
  31368. * @param mesh defines the source mesh
  31369. * @param id defines the unique ID of the new geometry object
  31370. * @returns the new geometry object
  31371. */
  31372. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31373. /**
  31374. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31375. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31376. * Be aware Math.random() could cause collisions, but:
  31377. * "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"
  31378. * @returns a string containing a new GUID
  31379. */
  31380. static RandomId(): string;
  31381. /** @hidden */
  31382. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31383. private static _CleanMatricesWeights;
  31384. /**
  31385. * Create a new geometry from persisted data (Using .babylon file format)
  31386. * @param parsedVertexData defines the persisted data
  31387. * @param scene defines the hosting scene
  31388. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31389. * @returns the new geometry object
  31390. */
  31391. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31392. }
  31393. }
  31394. declare module BABYLON {
  31395. /**
  31396. * Defines a target to use with MorphTargetManager
  31397. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31398. */
  31399. export class MorphTarget implements IAnimatable {
  31400. /** defines the name of the target */
  31401. name: string;
  31402. /**
  31403. * Gets or sets the list of animations
  31404. */
  31405. animations: Animation[];
  31406. private _scene;
  31407. private _positions;
  31408. private _normals;
  31409. private _tangents;
  31410. private _uvs;
  31411. private _influence;
  31412. private _uniqueId;
  31413. /**
  31414. * Observable raised when the influence changes
  31415. */
  31416. onInfluenceChanged: Observable<boolean>;
  31417. /** @hidden */
  31418. _onDataLayoutChanged: Observable<void>;
  31419. /**
  31420. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31421. */
  31422. get influence(): number;
  31423. set influence(influence: number);
  31424. /**
  31425. * Gets or sets the id of the morph Target
  31426. */
  31427. id: string;
  31428. private _animationPropertiesOverride;
  31429. /**
  31430. * Gets or sets the animation properties override
  31431. */
  31432. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31433. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31434. /**
  31435. * Creates a new MorphTarget
  31436. * @param name defines the name of the target
  31437. * @param influence defines the influence to use
  31438. * @param scene defines the scene the morphtarget belongs to
  31439. */
  31440. constructor(
  31441. /** defines the name of the target */
  31442. name: string, influence?: number, scene?: Nullable<Scene>);
  31443. /**
  31444. * Gets the unique ID of this manager
  31445. */
  31446. get uniqueId(): number;
  31447. /**
  31448. * Gets a boolean defining if the target contains position data
  31449. */
  31450. get hasPositions(): boolean;
  31451. /**
  31452. * Gets a boolean defining if the target contains normal data
  31453. */
  31454. get hasNormals(): boolean;
  31455. /**
  31456. * Gets a boolean defining if the target contains tangent data
  31457. */
  31458. get hasTangents(): boolean;
  31459. /**
  31460. * Gets a boolean defining if the target contains texture coordinates data
  31461. */
  31462. get hasUVs(): boolean;
  31463. /**
  31464. * Affects position data to this target
  31465. * @param data defines the position data to use
  31466. */
  31467. setPositions(data: Nullable<FloatArray>): void;
  31468. /**
  31469. * Gets the position data stored in this target
  31470. * @returns a FloatArray containing the position data (or null if not present)
  31471. */
  31472. getPositions(): Nullable<FloatArray>;
  31473. /**
  31474. * Affects normal data to this target
  31475. * @param data defines the normal data to use
  31476. */
  31477. setNormals(data: Nullable<FloatArray>): void;
  31478. /**
  31479. * Gets the normal data stored in this target
  31480. * @returns a FloatArray containing the normal data (or null if not present)
  31481. */
  31482. getNormals(): Nullable<FloatArray>;
  31483. /**
  31484. * Affects tangent data to this target
  31485. * @param data defines the tangent data to use
  31486. */
  31487. setTangents(data: Nullable<FloatArray>): void;
  31488. /**
  31489. * Gets the tangent data stored in this target
  31490. * @returns a FloatArray containing the tangent data (or null if not present)
  31491. */
  31492. getTangents(): Nullable<FloatArray>;
  31493. /**
  31494. * Affects texture coordinates data to this target
  31495. * @param data defines the texture coordinates data to use
  31496. */
  31497. setUVs(data: Nullable<FloatArray>): void;
  31498. /**
  31499. * Gets the texture coordinates data stored in this target
  31500. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31501. */
  31502. getUVs(): Nullable<FloatArray>;
  31503. /**
  31504. * Clone the current target
  31505. * @returns a new MorphTarget
  31506. */
  31507. clone(): MorphTarget;
  31508. /**
  31509. * Serializes the current target into a Serialization object
  31510. * @returns the serialized object
  31511. */
  31512. serialize(): any;
  31513. /**
  31514. * Returns the string "MorphTarget"
  31515. * @returns "MorphTarget"
  31516. */
  31517. getClassName(): string;
  31518. /**
  31519. * Creates a new target from serialized data
  31520. * @param serializationObject defines the serialized data to use
  31521. * @returns a new MorphTarget
  31522. */
  31523. static Parse(serializationObject: any): MorphTarget;
  31524. /**
  31525. * Creates a MorphTarget from mesh data
  31526. * @param mesh defines the source mesh
  31527. * @param name defines the name to use for the new target
  31528. * @param influence defines the influence to attach to the target
  31529. * @returns a new MorphTarget
  31530. */
  31531. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31532. }
  31533. }
  31534. declare module BABYLON {
  31535. /**
  31536. * This class is used to deform meshes using morphing between different targets
  31537. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31538. */
  31539. export class MorphTargetManager {
  31540. private _targets;
  31541. private _targetInfluenceChangedObservers;
  31542. private _targetDataLayoutChangedObservers;
  31543. private _activeTargets;
  31544. private _scene;
  31545. private _influences;
  31546. private _supportsNormals;
  31547. private _supportsTangents;
  31548. private _supportsUVs;
  31549. private _vertexCount;
  31550. private _uniqueId;
  31551. private _tempInfluences;
  31552. /**
  31553. * Gets or sets a boolean indicating if normals must be morphed
  31554. */
  31555. enableNormalMorphing: boolean;
  31556. /**
  31557. * Gets or sets a boolean indicating if tangents must be morphed
  31558. */
  31559. enableTangentMorphing: boolean;
  31560. /**
  31561. * Gets or sets a boolean indicating if UV must be morphed
  31562. */
  31563. enableUVMorphing: boolean;
  31564. /**
  31565. * Creates a new MorphTargetManager
  31566. * @param scene defines the current scene
  31567. */
  31568. constructor(scene?: Nullable<Scene>);
  31569. /**
  31570. * Gets the unique ID of this manager
  31571. */
  31572. get uniqueId(): number;
  31573. /**
  31574. * Gets the number of vertices handled by this manager
  31575. */
  31576. get vertexCount(): number;
  31577. /**
  31578. * Gets a boolean indicating if this manager supports morphing of normals
  31579. */
  31580. get supportsNormals(): boolean;
  31581. /**
  31582. * Gets a boolean indicating if this manager supports morphing of tangents
  31583. */
  31584. get supportsTangents(): boolean;
  31585. /**
  31586. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31587. */
  31588. get supportsUVs(): boolean;
  31589. /**
  31590. * Gets the number of targets stored in this manager
  31591. */
  31592. get numTargets(): number;
  31593. /**
  31594. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31595. */
  31596. get numInfluencers(): number;
  31597. /**
  31598. * Gets the list of influences (one per target)
  31599. */
  31600. get influences(): Float32Array;
  31601. /**
  31602. * Gets the active target at specified index. An active target is a target with an influence > 0
  31603. * @param index defines the index to check
  31604. * @returns the requested target
  31605. */
  31606. getActiveTarget(index: number): MorphTarget;
  31607. /**
  31608. * Gets the target at specified index
  31609. * @param index defines the index to check
  31610. * @returns the requested target
  31611. */
  31612. getTarget(index: number): MorphTarget;
  31613. /**
  31614. * Add a new target to this manager
  31615. * @param target defines the target to add
  31616. */
  31617. addTarget(target: MorphTarget): void;
  31618. /**
  31619. * Removes a target from the manager
  31620. * @param target defines the target to remove
  31621. */
  31622. removeTarget(target: MorphTarget): void;
  31623. /**
  31624. * Clone the current manager
  31625. * @returns a new MorphTargetManager
  31626. */
  31627. clone(): MorphTargetManager;
  31628. /**
  31629. * Serializes the current manager into a Serialization object
  31630. * @returns the serialized object
  31631. */
  31632. serialize(): any;
  31633. private _syncActiveTargets;
  31634. /**
  31635. * Syncrhonize the targets with all the meshes using this morph target manager
  31636. */
  31637. synchronize(): void;
  31638. /**
  31639. * Creates a new MorphTargetManager from serialized data
  31640. * @param serializationObject defines the serialized data
  31641. * @param scene defines the hosting scene
  31642. * @returns the new MorphTargetManager
  31643. */
  31644. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31645. }
  31646. }
  31647. declare module BABYLON {
  31648. /**
  31649. * Class used to represent a specific level of detail of a mesh
  31650. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31651. */
  31652. export class MeshLODLevel {
  31653. /** Defines the distance where this level should start being displayed */
  31654. distance: number;
  31655. /** Defines the mesh to use to render this level */
  31656. mesh: Nullable<Mesh>;
  31657. /**
  31658. * Creates a new LOD level
  31659. * @param distance defines the distance where this level should star being displayed
  31660. * @param mesh defines the mesh to use to render this level
  31661. */
  31662. constructor(
  31663. /** Defines the distance where this level should start being displayed */
  31664. distance: number,
  31665. /** Defines the mesh to use to render this level */
  31666. mesh: Nullable<Mesh>);
  31667. }
  31668. }
  31669. declare module BABYLON {
  31670. /**
  31671. * Helper class used to generate a canvas to manipulate images
  31672. */
  31673. export class CanvasGenerator {
  31674. /**
  31675. * Create a new canvas (or offscreen canvas depending on the context)
  31676. * @param width defines the expected width
  31677. * @param height defines the expected height
  31678. * @return a new canvas or offscreen canvas
  31679. */
  31680. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31681. }
  31682. }
  31683. declare module BABYLON {
  31684. /**
  31685. * Mesh representing the gorund
  31686. */
  31687. export class GroundMesh extends Mesh {
  31688. /** If octree should be generated */
  31689. generateOctree: boolean;
  31690. private _heightQuads;
  31691. /** @hidden */
  31692. _subdivisionsX: number;
  31693. /** @hidden */
  31694. _subdivisionsY: number;
  31695. /** @hidden */
  31696. _width: number;
  31697. /** @hidden */
  31698. _height: number;
  31699. /** @hidden */
  31700. _minX: number;
  31701. /** @hidden */
  31702. _maxX: number;
  31703. /** @hidden */
  31704. _minZ: number;
  31705. /** @hidden */
  31706. _maxZ: number;
  31707. constructor(name: string, scene: Scene);
  31708. /**
  31709. * "GroundMesh"
  31710. * @returns "GroundMesh"
  31711. */
  31712. getClassName(): string;
  31713. /**
  31714. * The minimum of x and y subdivisions
  31715. */
  31716. get subdivisions(): number;
  31717. /**
  31718. * X subdivisions
  31719. */
  31720. get subdivisionsX(): number;
  31721. /**
  31722. * Y subdivisions
  31723. */
  31724. get subdivisionsY(): number;
  31725. /**
  31726. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31727. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31728. * @param chunksCount the number of subdivisions for x and y
  31729. * @param octreeBlocksSize (Default: 32)
  31730. */
  31731. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31732. /**
  31733. * Returns a height (y) value in the Worl system :
  31734. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31735. * @param x x coordinate
  31736. * @param z z coordinate
  31737. * @returns the ground y position if (x, z) are outside the ground surface.
  31738. */
  31739. getHeightAtCoordinates(x: number, z: number): number;
  31740. /**
  31741. * Returns a normalized vector (Vector3) orthogonal to the ground
  31742. * at the ground coordinates (x, z) expressed in the World system.
  31743. * @param x x coordinate
  31744. * @param z z coordinate
  31745. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31746. */
  31747. getNormalAtCoordinates(x: number, z: number): Vector3;
  31748. /**
  31749. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31750. * at the ground coordinates (x, z) expressed in the World system.
  31751. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31752. * @param x x coordinate
  31753. * @param z z coordinate
  31754. * @param ref vector to store the result
  31755. * @returns the GroundMesh.
  31756. */
  31757. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31758. /**
  31759. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31760. * if the ground has been updated.
  31761. * This can be used in the render loop.
  31762. * @returns the GroundMesh.
  31763. */
  31764. updateCoordinateHeights(): GroundMesh;
  31765. private _getFacetAt;
  31766. private _initHeightQuads;
  31767. private _computeHeightQuads;
  31768. /**
  31769. * Serializes this ground mesh
  31770. * @param serializationObject object to write serialization to
  31771. */
  31772. serialize(serializationObject: any): void;
  31773. /**
  31774. * Parses a serialized ground mesh
  31775. * @param parsedMesh the serialized mesh
  31776. * @param scene the scene to create the ground mesh in
  31777. * @returns the created ground mesh
  31778. */
  31779. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31780. }
  31781. }
  31782. declare module BABYLON {
  31783. /**
  31784. * Interface for Physics-Joint data
  31785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31786. */
  31787. export interface PhysicsJointData {
  31788. /**
  31789. * The main pivot of the joint
  31790. */
  31791. mainPivot?: Vector3;
  31792. /**
  31793. * The connected pivot of the joint
  31794. */
  31795. connectedPivot?: Vector3;
  31796. /**
  31797. * The main axis of the joint
  31798. */
  31799. mainAxis?: Vector3;
  31800. /**
  31801. * The connected axis of the joint
  31802. */
  31803. connectedAxis?: Vector3;
  31804. /**
  31805. * The collision of the joint
  31806. */
  31807. collision?: boolean;
  31808. /**
  31809. * Native Oimo/Cannon/Energy data
  31810. */
  31811. nativeParams?: any;
  31812. }
  31813. /**
  31814. * This is a holder class for the physics joint created by the physics plugin
  31815. * It holds a set of functions to control the underlying joint
  31816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31817. */
  31818. export class PhysicsJoint {
  31819. /**
  31820. * The type of the physics joint
  31821. */
  31822. type: number;
  31823. /**
  31824. * The data for the physics joint
  31825. */
  31826. jointData: PhysicsJointData;
  31827. private _physicsJoint;
  31828. protected _physicsPlugin: IPhysicsEnginePlugin;
  31829. /**
  31830. * Initializes the physics joint
  31831. * @param type The type of the physics joint
  31832. * @param jointData The data for the physics joint
  31833. */
  31834. constructor(
  31835. /**
  31836. * The type of the physics joint
  31837. */
  31838. type: number,
  31839. /**
  31840. * The data for the physics joint
  31841. */
  31842. jointData: PhysicsJointData);
  31843. /**
  31844. * Gets the physics joint
  31845. */
  31846. get physicsJoint(): any;
  31847. /**
  31848. * Sets the physics joint
  31849. */
  31850. set physicsJoint(newJoint: any);
  31851. /**
  31852. * Sets the physics plugin
  31853. */
  31854. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31855. /**
  31856. * Execute a function that is physics-plugin specific.
  31857. * @param {Function} func the function that will be executed.
  31858. * It accepts two parameters: the physics world and the physics joint
  31859. */
  31860. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31861. /**
  31862. * Distance-Joint type
  31863. */
  31864. static DistanceJoint: number;
  31865. /**
  31866. * Hinge-Joint type
  31867. */
  31868. static HingeJoint: number;
  31869. /**
  31870. * Ball-and-Socket joint type
  31871. */
  31872. static BallAndSocketJoint: number;
  31873. /**
  31874. * Wheel-Joint type
  31875. */
  31876. static WheelJoint: number;
  31877. /**
  31878. * Slider-Joint type
  31879. */
  31880. static SliderJoint: number;
  31881. /**
  31882. * Prismatic-Joint type
  31883. */
  31884. static PrismaticJoint: number;
  31885. /**
  31886. * Universal-Joint type
  31887. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31888. */
  31889. static UniversalJoint: number;
  31890. /**
  31891. * Hinge-Joint 2 type
  31892. */
  31893. static Hinge2Joint: number;
  31894. /**
  31895. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31896. */
  31897. static PointToPointJoint: number;
  31898. /**
  31899. * Spring-Joint type
  31900. */
  31901. static SpringJoint: number;
  31902. /**
  31903. * Lock-Joint type
  31904. */
  31905. static LockJoint: number;
  31906. }
  31907. /**
  31908. * A class representing a physics distance joint
  31909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31910. */
  31911. export class DistanceJoint extends PhysicsJoint {
  31912. /**
  31913. *
  31914. * @param jointData The data for the Distance-Joint
  31915. */
  31916. constructor(jointData: DistanceJointData);
  31917. /**
  31918. * Update the predefined distance.
  31919. * @param maxDistance The maximum preferred distance
  31920. * @param minDistance The minimum preferred distance
  31921. */
  31922. updateDistance(maxDistance: number, minDistance?: number): void;
  31923. }
  31924. /**
  31925. * Represents a Motor-Enabled Joint
  31926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31927. */
  31928. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31929. /**
  31930. * Initializes the Motor-Enabled Joint
  31931. * @param type The type of the joint
  31932. * @param jointData The physica joint data for the joint
  31933. */
  31934. constructor(type: number, jointData: PhysicsJointData);
  31935. /**
  31936. * Set the motor values.
  31937. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31938. * @param force the force to apply
  31939. * @param maxForce max force for this motor.
  31940. */
  31941. setMotor(force?: number, maxForce?: number): void;
  31942. /**
  31943. * Set the motor's limits.
  31944. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31945. * @param upperLimit The upper limit of the motor
  31946. * @param lowerLimit The lower limit of the motor
  31947. */
  31948. setLimit(upperLimit: number, lowerLimit?: number): void;
  31949. }
  31950. /**
  31951. * This class represents a single physics Hinge-Joint
  31952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31953. */
  31954. export class HingeJoint extends MotorEnabledJoint {
  31955. /**
  31956. * Initializes the Hinge-Joint
  31957. * @param jointData The joint data for the Hinge-Joint
  31958. */
  31959. constructor(jointData: PhysicsJointData);
  31960. /**
  31961. * Set the motor values.
  31962. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31963. * @param {number} force the force to apply
  31964. * @param {number} maxForce max force for this motor.
  31965. */
  31966. setMotor(force?: number, maxForce?: number): void;
  31967. /**
  31968. * Set the motor's limits.
  31969. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31970. * @param upperLimit The upper limit of the motor
  31971. * @param lowerLimit The lower limit of the motor
  31972. */
  31973. setLimit(upperLimit: number, lowerLimit?: number): void;
  31974. }
  31975. /**
  31976. * This class represents a dual hinge physics joint (same as wheel joint)
  31977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31978. */
  31979. export class Hinge2Joint extends MotorEnabledJoint {
  31980. /**
  31981. * Initializes the Hinge2-Joint
  31982. * @param jointData The joint data for the Hinge2-Joint
  31983. */
  31984. constructor(jointData: PhysicsJointData);
  31985. /**
  31986. * Set the motor values.
  31987. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31988. * @param {number} targetSpeed the speed the motor is to reach
  31989. * @param {number} maxForce max force for this motor.
  31990. * @param {motorIndex} the motor's index, 0 or 1.
  31991. */
  31992. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31993. /**
  31994. * Set the motor limits.
  31995. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31996. * @param {number} upperLimit the upper limit
  31997. * @param {number} lowerLimit lower limit
  31998. * @param {motorIndex} the motor's index, 0 or 1.
  31999. */
  32000. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32001. }
  32002. /**
  32003. * Interface for a motor enabled joint
  32004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32005. */
  32006. export interface IMotorEnabledJoint {
  32007. /**
  32008. * Physics joint
  32009. */
  32010. physicsJoint: any;
  32011. /**
  32012. * Sets the motor of the motor-enabled joint
  32013. * @param force The force of the motor
  32014. * @param maxForce The maximum force of the motor
  32015. * @param motorIndex The index of the motor
  32016. */
  32017. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32018. /**
  32019. * Sets the limit of the motor
  32020. * @param upperLimit The upper limit of the motor
  32021. * @param lowerLimit The lower limit of the motor
  32022. * @param motorIndex The index of the motor
  32023. */
  32024. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32025. }
  32026. /**
  32027. * Joint data for a Distance-Joint
  32028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32029. */
  32030. export interface DistanceJointData extends PhysicsJointData {
  32031. /**
  32032. * Max distance the 2 joint objects can be apart
  32033. */
  32034. maxDistance: number;
  32035. }
  32036. /**
  32037. * Joint data from a spring joint
  32038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32039. */
  32040. export interface SpringJointData extends PhysicsJointData {
  32041. /**
  32042. * Length of the spring
  32043. */
  32044. length: number;
  32045. /**
  32046. * Stiffness of the spring
  32047. */
  32048. stiffness: number;
  32049. /**
  32050. * Damping of the spring
  32051. */
  32052. damping: number;
  32053. /** this callback will be called when applying the force to the impostors. */
  32054. forceApplicationCallback: () => void;
  32055. }
  32056. }
  32057. declare module BABYLON {
  32058. /**
  32059. * Holds the data for the raycast result
  32060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32061. */
  32062. export class PhysicsRaycastResult {
  32063. private _hasHit;
  32064. private _hitDistance;
  32065. private _hitNormalWorld;
  32066. private _hitPointWorld;
  32067. private _rayFromWorld;
  32068. private _rayToWorld;
  32069. /**
  32070. * Gets if there was a hit
  32071. */
  32072. get hasHit(): boolean;
  32073. /**
  32074. * Gets the distance from the hit
  32075. */
  32076. get hitDistance(): number;
  32077. /**
  32078. * Gets the hit normal/direction in the world
  32079. */
  32080. get hitNormalWorld(): Vector3;
  32081. /**
  32082. * Gets the hit point in the world
  32083. */
  32084. get hitPointWorld(): Vector3;
  32085. /**
  32086. * Gets the ray "start point" of the ray in the world
  32087. */
  32088. get rayFromWorld(): Vector3;
  32089. /**
  32090. * Gets the ray "end point" of the ray in the world
  32091. */
  32092. get rayToWorld(): Vector3;
  32093. /**
  32094. * Sets the hit data (normal & point in world space)
  32095. * @param hitNormalWorld defines the normal in world space
  32096. * @param hitPointWorld defines the point in world space
  32097. */
  32098. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32099. /**
  32100. * Sets the distance from the start point to the hit point
  32101. * @param distance
  32102. */
  32103. setHitDistance(distance: number): void;
  32104. /**
  32105. * Calculates the distance manually
  32106. */
  32107. calculateHitDistance(): void;
  32108. /**
  32109. * Resets all the values to default
  32110. * @param from The from point on world space
  32111. * @param to The to point on world space
  32112. */
  32113. reset(from?: Vector3, to?: Vector3): void;
  32114. }
  32115. /**
  32116. * Interface for the size containing width and height
  32117. */
  32118. interface IXYZ {
  32119. /**
  32120. * X
  32121. */
  32122. x: number;
  32123. /**
  32124. * Y
  32125. */
  32126. y: number;
  32127. /**
  32128. * Z
  32129. */
  32130. z: number;
  32131. }
  32132. }
  32133. declare module BABYLON {
  32134. /**
  32135. * Interface used to describe a physics joint
  32136. */
  32137. export interface PhysicsImpostorJoint {
  32138. /** Defines the main impostor to which the joint is linked */
  32139. mainImpostor: PhysicsImpostor;
  32140. /** Defines the impostor that is connected to the main impostor using this joint */
  32141. connectedImpostor: PhysicsImpostor;
  32142. /** Defines the joint itself */
  32143. joint: PhysicsJoint;
  32144. }
  32145. /** @hidden */
  32146. export interface IPhysicsEnginePlugin {
  32147. world: any;
  32148. name: string;
  32149. setGravity(gravity: Vector3): void;
  32150. setTimeStep(timeStep: number): void;
  32151. getTimeStep(): number;
  32152. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32153. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32154. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32155. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32156. removePhysicsBody(impostor: PhysicsImpostor): void;
  32157. generateJoint(joint: PhysicsImpostorJoint): void;
  32158. removeJoint(joint: PhysicsImpostorJoint): void;
  32159. isSupported(): boolean;
  32160. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32161. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32162. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32163. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32164. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32165. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32166. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32167. getBodyMass(impostor: PhysicsImpostor): number;
  32168. getBodyFriction(impostor: PhysicsImpostor): number;
  32169. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32170. getBodyRestitution(impostor: PhysicsImpostor): number;
  32171. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32172. getBodyPressure?(impostor: PhysicsImpostor): number;
  32173. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32174. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32175. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32176. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32177. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32178. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32179. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32180. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32181. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32182. sleepBody(impostor: PhysicsImpostor): void;
  32183. wakeUpBody(impostor: PhysicsImpostor): void;
  32184. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32185. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32186. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32187. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32188. getRadius(impostor: PhysicsImpostor): number;
  32189. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32190. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32191. dispose(): void;
  32192. }
  32193. /**
  32194. * Interface used to define a physics engine
  32195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32196. */
  32197. export interface IPhysicsEngine {
  32198. /**
  32199. * Gets the gravity vector used by the simulation
  32200. */
  32201. gravity: Vector3;
  32202. /**
  32203. * Sets the gravity vector used by the simulation
  32204. * @param gravity defines the gravity vector to use
  32205. */
  32206. setGravity(gravity: Vector3): void;
  32207. /**
  32208. * Set the time step of the physics engine.
  32209. * Default is 1/60.
  32210. * To slow it down, enter 1/600 for example.
  32211. * To speed it up, 1/30
  32212. * @param newTimeStep the new timestep to apply to this world.
  32213. */
  32214. setTimeStep(newTimeStep: number): void;
  32215. /**
  32216. * Get the time step of the physics engine.
  32217. * @returns the current time step
  32218. */
  32219. getTimeStep(): number;
  32220. /**
  32221. * Set the sub time step of the physics engine.
  32222. * Default is 0 meaning there is no sub steps
  32223. * To increase physics resolution precision, set a small value (like 1 ms)
  32224. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32225. */
  32226. setSubTimeStep(subTimeStep: number): void;
  32227. /**
  32228. * Get the sub time step of the physics engine.
  32229. * @returns the current sub time step
  32230. */
  32231. getSubTimeStep(): number;
  32232. /**
  32233. * Release all resources
  32234. */
  32235. dispose(): void;
  32236. /**
  32237. * Gets the name of the current physics plugin
  32238. * @returns the name of the plugin
  32239. */
  32240. getPhysicsPluginName(): string;
  32241. /**
  32242. * Adding a new impostor for the impostor tracking.
  32243. * This will be done by the impostor itself.
  32244. * @param impostor the impostor to add
  32245. */
  32246. addImpostor(impostor: PhysicsImpostor): void;
  32247. /**
  32248. * Remove an impostor from the engine.
  32249. * This impostor and its mesh will not longer be updated by the physics engine.
  32250. * @param impostor the impostor to remove
  32251. */
  32252. removeImpostor(impostor: PhysicsImpostor): void;
  32253. /**
  32254. * Add a joint to the physics engine
  32255. * @param mainImpostor defines the main impostor to which the joint is added.
  32256. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32257. * @param joint defines the joint that will connect both impostors.
  32258. */
  32259. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32260. /**
  32261. * Removes a joint from the simulation
  32262. * @param mainImpostor defines the impostor used with the joint
  32263. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32264. * @param joint defines the joint to remove
  32265. */
  32266. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32267. /**
  32268. * Gets the current plugin used to run the simulation
  32269. * @returns current plugin
  32270. */
  32271. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32272. /**
  32273. * Gets the list of physic impostors
  32274. * @returns an array of PhysicsImpostor
  32275. */
  32276. getImpostors(): Array<PhysicsImpostor>;
  32277. /**
  32278. * Gets the impostor for a physics enabled object
  32279. * @param object defines the object impersonated by the impostor
  32280. * @returns the PhysicsImpostor or null if not found
  32281. */
  32282. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32283. /**
  32284. * Gets the impostor for a physics body object
  32285. * @param body defines physics body used by the impostor
  32286. * @returns the PhysicsImpostor or null if not found
  32287. */
  32288. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32289. /**
  32290. * Does a raycast in the physics world
  32291. * @param from when should the ray start?
  32292. * @param to when should the ray end?
  32293. * @returns PhysicsRaycastResult
  32294. */
  32295. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32296. /**
  32297. * Called by the scene. No need to call it.
  32298. * @param delta defines the timespam between frames
  32299. */
  32300. _step(delta: number): void;
  32301. }
  32302. }
  32303. declare module BABYLON {
  32304. /**
  32305. * The interface for the physics imposter parameters
  32306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32307. */
  32308. export interface PhysicsImpostorParameters {
  32309. /**
  32310. * The mass of the physics imposter
  32311. */
  32312. mass: number;
  32313. /**
  32314. * The friction of the physics imposter
  32315. */
  32316. friction?: number;
  32317. /**
  32318. * The coefficient of restitution of the physics imposter
  32319. */
  32320. restitution?: number;
  32321. /**
  32322. * The native options of the physics imposter
  32323. */
  32324. nativeOptions?: any;
  32325. /**
  32326. * Specifies if the parent should be ignored
  32327. */
  32328. ignoreParent?: boolean;
  32329. /**
  32330. * Specifies if bi-directional transformations should be disabled
  32331. */
  32332. disableBidirectionalTransformation?: boolean;
  32333. /**
  32334. * The pressure inside the physics imposter, soft object only
  32335. */
  32336. pressure?: number;
  32337. /**
  32338. * The stiffness the physics imposter, soft object only
  32339. */
  32340. stiffness?: number;
  32341. /**
  32342. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32343. */
  32344. velocityIterations?: number;
  32345. /**
  32346. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32347. */
  32348. positionIterations?: number;
  32349. /**
  32350. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32351. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32352. * Add to fix multiple points
  32353. */
  32354. fixedPoints?: number;
  32355. /**
  32356. * The collision margin around a soft object
  32357. */
  32358. margin?: number;
  32359. /**
  32360. * The collision margin around a soft object
  32361. */
  32362. damping?: number;
  32363. /**
  32364. * The path for a rope based on an extrusion
  32365. */
  32366. path?: any;
  32367. /**
  32368. * The shape of an extrusion used for a rope based on an extrusion
  32369. */
  32370. shape?: any;
  32371. }
  32372. /**
  32373. * Interface for a physics-enabled object
  32374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32375. */
  32376. export interface IPhysicsEnabledObject {
  32377. /**
  32378. * The position of the physics-enabled object
  32379. */
  32380. position: Vector3;
  32381. /**
  32382. * The rotation of the physics-enabled object
  32383. */
  32384. rotationQuaternion: Nullable<Quaternion>;
  32385. /**
  32386. * The scale of the physics-enabled object
  32387. */
  32388. scaling: Vector3;
  32389. /**
  32390. * The rotation of the physics-enabled object
  32391. */
  32392. rotation?: Vector3;
  32393. /**
  32394. * The parent of the physics-enabled object
  32395. */
  32396. parent?: any;
  32397. /**
  32398. * The bounding info of the physics-enabled object
  32399. * @returns The bounding info of the physics-enabled object
  32400. */
  32401. getBoundingInfo(): BoundingInfo;
  32402. /**
  32403. * Computes the world matrix
  32404. * @param force Specifies if the world matrix should be computed by force
  32405. * @returns A world matrix
  32406. */
  32407. computeWorldMatrix(force: boolean): Matrix;
  32408. /**
  32409. * Gets the world matrix
  32410. * @returns A world matrix
  32411. */
  32412. getWorldMatrix?(): Matrix;
  32413. /**
  32414. * Gets the child meshes
  32415. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32416. * @returns An array of abstract meshes
  32417. */
  32418. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32419. /**
  32420. * Gets the vertex data
  32421. * @param kind The type of vertex data
  32422. * @returns A nullable array of numbers, or a float32 array
  32423. */
  32424. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32425. /**
  32426. * Gets the indices from the mesh
  32427. * @returns A nullable array of index arrays
  32428. */
  32429. getIndices?(): Nullable<IndicesArray>;
  32430. /**
  32431. * Gets the scene from the mesh
  32432. * @returns the indices array or null
  32433. */
  32434. getScene?(): Scene;
  32435. /**
  32436. * Gets the absolute position from the mesh
  32437. * @returns the absolute position
  32438. */
  32439. getAbsolutePosition(): Vector3;
  32440. /**
  32441. * Gets the absolute pivot point from the mesh
  32442. * @returns the absolute pivot point
  32443. */
  32444. getAbsolutePivotPoint(): Vector3;
  32445. /**
  32446. * Rotates the mesh
  32447. * @param axis The axis of rotation
  32448. * @param amount The amount of rotation
  32449. * @param space The space of the rotation
  32450. * @returns The rotation transform node
  32451. */
  32452. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32453. /**
  32454. * Translates the mesh
  32455. * @param axis The axis of translation
  32456. * @param distance The distance of translation
  32457. * @param space The space of the translation
  32458. * @returns The transform node
  32459. */
  32460. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32461. /**
  32462. * Sets the absolute position of the mesh
  32463. * @param absolutePosition The absolute position of the mesh
  32464. * @returns The transform node
  32465. */
  32466. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32467. /**
  32468. * Gets the class name of the mesh
  32469. * @returns The class name
  32470. */
  32471. getClassName(): string;
  32472. }
  32473. /**
  32474. * Represents a physics imposter
  32475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32476. */
  32477. export class PhysicsImpostor {
  32478. /**
  32479. * The physics-enabled object used as the physics imposter
  32480. */
  32481. object: IPhysicsEnabledObject;
  32482. /**
  32483. * The type of the physics imposter
  32484. */
  32485. type: number;
  32486. private _options;
  32487. private _scene?;
  32488. /**
  32489. * The default object size of the imposter
  32490. */
  32491. static DEFAULT_OBJECT_SIZE: Vector3;
  32492. /**
  32493. * The identity quaternion of the imposter
  32494. */
  32495. static IDENTITY_QUATERNION: Quaternion;
  32496. /** @hidden */
  32497. _pluginData: any;
  32498. private _physicsEngine;
  32499. private _physicsBody;
  32500. private _bodyUpdateRequired;
  32501. private _onBeforePhysicsStepCallbacks;
  32502. private _onAfterPhysicsStepCallbacks;
  32503. /** @hidden */
  32504. _onPhysicsCollideCallbacks: Array<{
  32505. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32506. otherImpostors: Array<PhysicsImpostor>;
  32507. }>;
  32508. private _deltaPosition;
  32509. private _deltaRotation;
  32510. private _deltaRotationConjugated;
  32511. /** @hidden */
  32512. _isFromLine: boolean;
  32513. private _parent;
  32514. private _isDisposed;
  32515. private static _tmpVecs;
  32516. private static _tmpQuat;
  32517. /**
  32518. * Specifies if the physics imposter is disposed
  32519. */
  32520. get isDisposed(): boolean;
  32521. /**
  32522. * Gets the mass of the physics imposter
  32523. */
  32524. get mass(): number;
  32525. set mass(value: number);
  32526. /**
  32527. * Gets the coefficient of friction
  32528. */
  32529. get friction(): number;
  32530. /**
  32531. * Sets the coefficient of friction
  32532. */
  32533. set friction(value: number);
  32534. /**
  32535. * Gets the coefficient of restitution
  32536. */
  32537. get restitution(): number;
  32538. /**
  32539. * Sets the coefficient of restitution
  32540. */
  32541. set restitution(value: number);
  32542. /**
  32543. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32544. */
  32545. get pressure(): number;
  32546. /**
  32547. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32548. */
  32549. set pressure(value: number);
  32550. /**
  32551. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32552. */
  32553. get stiffness(): number;
  32554. /**
  32555. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32556. */
  32557. set stiffness(value: number);
  32558. /**
  32559. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32560. */
  32561. get velocityIterations(): number;
  32562. /**
  32563. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32564. */
  32565. set velocityIterations(value: number);
  32566. /**
  32567. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32568. */
  32569. get positionIterations(): number;
  32570. /**
  32571. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32572. */
  32573. set positionIterations(value: number);
  32574. /**
  32575. * The unique id of the physics imposter
  32576. * set by the physics engine when adding this impostor to the array
  32577. */
  32578. uniqueId: number;
  32579. /**
  32580. * @hidden
  32581. */
  32582. soft: boolean;
  32583. /**
  32584. * @hidden
  32585. */
  32586. segments: number;
  32587. private _joints;
  32588. /**
  32589. * Initializes the physics imposter
  32590. * @param object The physics-enabled object used as the physics imposter
  32591. * @param type The type of the physics imposter
  32592. * @param _options The options for the physics imposter
  32593. * @param _scene The Babylon scene
  32594. */
  32595. constructor(
  32596. /**
  32597. * The physics-enabled object used as the physics imposter
  32598. */
  32599. object: IPhysicsEnabledObject,
  32600. /**
  32601. * The type of the physics imposter
  32602. */
  32603. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32604. /**
  32605. * This function will completly initialize this impostor.
  32606. * It will create a new body - but only if this mesh has no parent.
  32607. * If it has, this impostor will not be used other than to define the impostor
  32608. * of the child mesh.
  32609. * @hidden
  32610. */
  32611. _init(): void;
  32612. private _getPhysicsParent;
  32613. /**
  32614. * Should a new body be generated.
  32615. * @returns boolean specifying if body initialization is required
  32616. */
  32617. isBodyInitRequired(): boolean;
  32618. /**
  32619. * Sets the updated scaling
  32620. * @param updated Specifies if the scaling is updated
  32621. */
  32622. setScalingUpdated(): void;
  32623. /**
  32624. * Force a regeneration of this or the parent's impostor's body.
  32625. * Use under cautious - This will remove all joints already implemented.
  32626. */
  32627. forceUpdate(): void;
  32628. /**
  32629. * Gets the body that holds this impostor. Either its own, or its parent.
  32630. */
  32631. get physicsBody(): any;
  32632. /**
  32633. * Get the parent of the physics imposter
  32634. * @returns Physics imposter or null
  32635. */
  32636. get parent(): Nullable<PhysicsImpostor>;
  32637. /**
  32638. * Sets the parent of the physics imposter
  32639. */
  32640. set parent(value: Nullable<PhysicsImpostor>);
  32641. /**
  32642. * Set the physics body. Used mainly by the physics engine/plugin
  32643. */
  32644. set physicsBody(physicsBody: any);
  32645. /**
  32646. * Resets the update flags
  32647. */
  32648. resetUpdateFlags(): void;
  32649. /**
  32650. * Gets the object extend size
  32651. * @returns the object extend size
  32652. */
  32653. getObjectExtendSize(): Vector3;
  32654. /**
  32655. * Gets the object center
  32656. * @returns The object center
  32657. */
  32658. getObjectCenter(): Vector3;
  32659. /**
  32660. * Get a specific parameter from the options parameters
  32661. * @param paramName The object parameter name
  32662. * @returns The object parameter
  32663. */
  32664. getParam(paramName: string): any;
  32665. /**
  32666. * Sets a specific parameter in the options given to the physics plugin
  32667. * @param paramName The parameter name
  32668. * @param value The value of the parameter
  32669. */
  32670. setParam(paramName: string, value: number): void;
  32671. /**
  32672. * Specifically change the body's mass option. Won't recreate the physics body object
  32673. * @param mass The mass of the physics imposter
  32674. */
  32675. setMass(mass: number): void;
  32676. /**
  32677. * Gets the linear velocity
  32678. * @returns linear velocity or null
  32679. */
  32680. getLinearVelocity(): Nullable<Vector3>;
  32681. /**
  32682. * Sets the linear velocity
  32683. * @param velocity linear velocity or null
  32684. */
  32685. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32686. /**
  32687. * Gets the angular velocity
  32688. * @returns angular velocity or null
  32689. */
  32690. getAngularVelocity(): Nullable<Vector3>;
  32691. /**
  32692. * Sets the angular velocity
  32693. * @param velocity The velocity or null
  32694. */
  32695. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32696. /**
  32697. * Execute a function with the physics plugin native code
  32698. * Provide a function the will have two variables - the world object and the physics body object
  32699. * @param func The function to execute with the physics plugin native code
  32700. */
  32701. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32702. /**
  32703. * Register a function that will be executed before the physics world is stepping forward
  32704. * @param func The function to execute before the physics world is stepped forward
  32705. */
  32706. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32707. /**
  32708. * Unregister a function that will be executed before the physics world is stepping forward
  32709. * @param func The function to execute before the physics world is stepped forward
  32710. */
  32711. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32712. /**
  32713. * Register a function that will be executed after the physics step
  32714. * @param func The function to execute after physics step
  32715. */
  32716. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32717. /**
  32718. * Unregisters a function that will be executed after the physics step
  32719. * @param func The function to execute after physics step
  32720. */
  32721. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32722. /**
  32723. * register a function that will be executed when this impostor collides against a different body
  32724. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32725. * @param func Callback that is executed on collision
  32726. */
  32727. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32728. /**
  32729. * Unregisters the physics imposter on contact
  32730. * @param collideAgainst The physics object to collide against
  32731. * @param func Callback to execute on collision
  32732. */
  32733. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32734. private _tmpQuat;
  32735. private _tmpQuat2;
  32736. /**
  32737. * Get the parent rotation
  32738. * @returns The parent rotation
  32739. */
  32740. getParentsRotation(): Quaternion;
  32741. /**
  32742. * this function is executed by the physics engine.
  32743. */
  32744. beforeStep: () => void;
  32745. /**
  32746. * this function is executed by the physics engine
  32747. */
  32748. afterStep: () => void;
  32749. /**
  32750. * Legacy collision detection event support
  32751. */
  32752. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32753. /**
  32754. * event and body object due to cannon's event-based architecture.
  32755. */
  32756. onCollide: (e: {
  32757. body: any;
  32758. point: Nullable<Vector3>;
  32759. }) => void;
  32760. /**
  32761. * Apply a force
  32762. * @param force The force to apply
  32763. * @param contactPoint The contact point for the force
  32764. * @returns The physics imposter
  32765. */
  32766. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32767. /**
  32768. * Apply an impulse
  32769. * @param force The impulse force
  32770. * @param contactPoint The contact point for the impulse force
  32771. * @returns The physics imposter
  32772. */
  32773. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32774. /**
  32775. * A help function to create a joint
  32776. * @param otherImpostor A physics imposter used to create a joint
  32777. * @param jointType The type of joint
  32778. * @param jointData The data for the joint
  32779. * @returns The physics imposter
  32780. */
  32781. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32782. /**
  32783. * Add a joint to this impostor with a different impostor
  32784. * @param otherImpostor A physics imposter used to add a joint
  32785. * @param joint The joint to add
  32786. * @returns The physics imposter
  32787. */
  32788. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32789. /**
  32790. * Add an anchor to a cloth impostor
  32791. * @param otherImpostor rigid impostor to anchor to
  32792. * @param width ratio across width from 0 to 1
  32793. * @param height ratio up height from 0 to 1
  32794. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32795. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32796. * @returns impostor the soft imposter
  32797. */
  32798. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32799. /**
  32800. * Add a hook to a rope impostor
  32801. * @param otherImpostor rigid impostor to anchor to
  32802. * @param length ratio across rope from 0 to 1
  32803. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32804. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32805. * @returns impostor the rope imposter
  32806. */
  32807. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32808. /**
  32809. * Will keep this body still, in a sleep mode.
  32810. * @returns the physics imposter
  32811. */
  32812. sleep(): PhysicsImpostor;
  32813. /**
  32814. * Wake the body up.
  32815. * @returns The physics imposter
  32816. */
  32817. wakeUp(): PhysicsImpostor;
  32818. /**
  32819. * Clones the physics imposter
  32820. * @param newObject The physics imposter clones to this physics-enabled object
  32821. * @returns A nullable physics imposter
  32822. */
  32823. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32824. /**
  32825. * Disposes the physics imposter
  32826. */
  32827. dispose(): void;
  32828. /**
  32829. * Sets the delta position
  32830. * @param position The delta position amount
  32831. */
  32832. setDeltaPosition(position: Vector3): void;
  32833. /**
  32834. * Sets the delta rotation
  32835. * @param rotation The delta rotation amount
  32836. */
  32837. setDeltaRotation(rotation: Quaternion): void;
  32838. /**
  32839. * Gets the box size of the physics imposter and stores the result in the input parameter
  32840. * @param result Stores the box size
  32841. * @returns The physics imposter
  32842. */
  32843. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32844. /**
  32845. * Gets the radius of the physics imposter
  32846. * @returns Radius of the physics imposter
  32847. */
  32848. getRadius(): number;
  32849. /**
  32850. * Sync a bone with this impostor
  32851. * @param bone The bone to sync to the impostor.
  32852. * @param boneMesh The mesh that the bone is influencing.
  32853. * @param jointPivot The pivot of the joint / bone in local space.
  32854. * @param distToJoint Optional distance from the impostor to the joint.
  32855. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32856. */
  32857. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32858. /**
  32859. * Sync impostor to a bone
  32860. * @param bone The bone that the impostor will be synced to.
  32861. * @param boneMesh The mesh that the bone is influencing.
  32862. * @param jointPivot The pivot of the joint / bone in local space.
  32863. * @param distToJoint Optional distance from the impostor to the joint.
  32864. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32865. * @param boneAxis Optional vector3 axis the bone is aligned with
  32866. */
  32867. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32868. /**
  32869. * No-Imposter type
  32870. */
  32871. static NoImpostor: number;
  32872. /**
  32873. * Sphere-Imposter type
  32874. */
  32875. static SphereImpostor: number;
  32876. /**
  32877. * Box-Imposter type
  32878. */
  32879. static BoxImpostor: number;
  32880. /**
  32881. * Plane-Imposter type
  32882. */
  32883. static PlaneImpostor: number;
  32884. /**
  32885. * Mesh-imposter type
  32886. */
  32887. static MeshImpostor: number;
  32888. /**
  32889. * Capsule-Impostor type (Ammo.js plugin only)
  32890. */
  32891. static CapsuleImpostor: number;
  32892. /**
  32893. * Cylinder-Imposter type
  32894. */
  32895. static CylinderImpostor: number;
  32896. /**
  32897. * Particle-Imposter type
  32898. */
  32899. static ParticleImpostor: number;
  32900. /**
  32901. * Heightmap-Imposter type
  32902. */
  32903. static HeightmapImpostor: number;
  32904. /**
  32905. * ConvexHull-Impostor type (Ammo.js plugin only)
  32906. */
  32907. static ConvexHullImpostor: number;
  32908. /**
  32909. * Custom-Imposter type (Ammo.js plugin only)
  32910. */
  32911. static CustomImpostor: number;
  32912. /**
  32913. * Rope-Imposter type
  32914. */
  32915. static RopeImpostor: number;
  32916. /**
  32917. * Cloth-Imposter type
  32918. */
  32919. static ClothImpostor: number;
  32920. /**
  32921. * Softbody-Imposter type
  32922. */
  32923. static SoftbodyImpostor: number;
  32924. }
  32925. }
  32926. declare module BABYLON {
  32927. /**
  32928. * @hidden
  32929. **/
  32930. export class _CreationDataStorage {
  32931. closePath?: boolean;
  32932. closeArray?: boolean;
  32933. idx: number[];
  32934. dashSize: number;
  32935. gapSize: number;
  32936. path3D: Path3D;
  32937. pathArray: Vector3[][];
  32938. arc: number;
  32939. radius: number;
  32940. cap: number;
  32941. tessellation: number;
  32942. }
  32943. /**
  32944. * @hidden
  32945. **/
  32946. class _InstanceDataStorage {
  32947. visibleInstances: any;
  32948. batchCache: _InstancesBatch;
  32949. instancesBufferSize: number;
  32950. instancesBuffer: Nullable<Buffer>;
  32951. instancesData: Float32Array;
  32952. overridenInstanceCount: number;
  32953. isFrozen: boolean;
  32954. previousBatch: Nullable<_InstancesBatch>;
  32955. hardwareInstancedRendering: boolean;
  32956. sideOrientation: number;
  32957. manualUpdate: boolean;
  32958. previousRenderId: number;
  32959. }
  32960. /**
  32961. * @hidden
  32962. **/
  32963. export class _InstancesBatch {
  32964. mustReturn: boolean;
  32965. visibleInstances: Nullable<InstancedMesh[]>[];
  32966. renderSelf: boolean[];
  32967. hardwareInstancedRendering: boolean[];
  32968. }
  32969. /**
  32970. * @hidden
  32971. **/
  32972. class _ThinInstanceDataStorage {
  32973. instancesCount: number;
  32974. matrixBuffer: Nullable<Buffer>;
  32975. matrixBufferSize: number;
  32976. matrixData: Nullable<Float32Array>;
  32977. boundingVectors: Array<Vector3>;
  32978. worldMatrices: Nullable<Matrix[]>;
  32979. }
  32980. /**
  32981. * Class used to represent renderable models
  32982. */
  32983. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32984. /**
  32985. * Mesh side orientation : usually the external or front surface
  32986. */
  32987. static readonly FRONTSIDE: number;
  32988. /**
  32989. * Mesh side orientation : usually the internal or back surface
  32990. */
  32991. static readonly BACKSIDE: number;
  32992. /**
  32993. * Mesh side orientation : both internal and external or front and back surfaces
  32994. */
  32995. static readonly DOUBLESIDE: number;
  32996. /**
  32997. * Mesh side orientation : by default, `FRONTSIDE`
  32998. */
  32999. static readonly DEFAULTSIDE: number;
  33000. /**
  33001. * Mesh cap setting : no cap
  33002. */
  33003. static readonly NO_CAP: number;
  33004. /**
  33005. * Mesh cap setting : one cap at the beginning of the mesh
  33006. */
  33007. static readonly CAP_START: number;
  33008. /**
  33009. * Mesh cap setting : one cap at the end of the mesh
  33010. */
  33011. static readonly CAP_END: number;
  33012. /**
  33013. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33014. */
  33015. static readonly CAP_ALL: number;
  33016. /**
  33017. * Mesh pattern setting : no flip or rotate
  33018. */
  33019. static readonly NO_FLIP: number;
  33020. /**
  33021. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33022. */
  33023. static readonly FLIP_TILE: number;
  33024. /**
  33025. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33026. */
  33027. static readonly ROTATE_TILE: number;
  33028. /**
  33029. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33030. */
  33031. static readonly FLIP_ROW: number;
  33032. /**
  33033. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33034. */
  33035. static readonly ROTATE_ROW: number;
  33036. /**
  33037. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33038. */
  33039. static readonly FLIP_N_ROTATE_TILE: number;
  33040. /**
  33041. * Mesh pattern setting : rotate pattern and rotate
  33042. */
  33043. static readonly FLIP_N_ROTATE_ROW: number;
  33044. /**
  33045. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33046. */
  33047. static readonly CENTER: number;
  33048. /**
  33049. * Mesh tile positioning : part tiles on left
  33050. */
  33051. static readonly LEFT: number;
  33052. /**
  33053. * Mesh tile positioning : part tiles on right
  33054. */
  33055. static readonly RIGHT: number;
  33056. /**
  33057. * Mesh tile positioning : part tiles on top
  33058. */
  33059. static readonly TOP: number;
  33060. /**
  33061. * Mesh tile positioning : part tiles on bottom
  33062. */
  33063. static readonly BOTTOM: number;
  33064. /**
  33065. * Gets the default side orientation.
  33066. * @param orientation the orientation to value to attempt to get
  33067. * @returns the default orientation
  33068. * @hidden
  33069. */
  33070. static _GetDefaultSideOrientation(orientation?: number): number;
  33071. private _internalMeshDataInfo;
  33072. get computeBonesUsingShaders(): boolean;
  33073. set computeBonesUsingShaders(value: boolean);
  33074. /**
  33075. * An event triggered before rendering the mesh
  33076. */
  33077. get onBeforeRenderObservable(): Observable<Mesh>;
  33078. /**
  33079. * An event triggered before binding the mesh
  33080. */
  33081. get onBeforeBindObservable(): Observable<Mesh>;
  33082. /**
  33083. * An event triggered after rendering the mesh
  33084. */
  33085. get onAfterRenderObservable(): Observable<Mesh>;
  33086. /**
  33087. * An event triggered before drawing the mesh
  33088. */
  33089. get onBeforeDrawObservable(): Observable<Mesh>;
  33090. private _onBeforeDrawObserver;
  33091. /**
  33092. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33093. */
  33094. set onBeforeDraw(callback: () => void);
  33095. get hasInstances(): boolean;
  33096. get hasThinInstances(): boolean;
  33097. /**
  33098. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33099. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33100. */
  33101. delayLoadState: number;
  33102. /**
  33103. * Gets the list of instances created from this mesh
  33104. * it is not supposed to be modified manually.
  33105. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33106. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33107. */
  33108. instances: InstancedMesh[];
  33109. /**
  33110. * Gets the file containing delay loading data for this mesh
  33111. */
  33112. delayLoadingFile: string;
  33113. /** @hidden */
  33114. _binaryInfo: any;
  33115. /**
  33116. * User defined function used to change how LOD level selection is done
  33117. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33118. */
  33119. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33120. /**
  33121. * Gets or sets the morph target manager
  33122. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33123. */
  33124. get morphTargetManager(): Nullable<MorphTargetManager>;
  33125. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33126. /** @hidden */
  33127. _creationDataStorage: Nullable<_CreationDataStorage>;
  33128. /** @hidden */
  33129. _geometry: Nullable<Geometry>;
  33130. /** @hidden */
  33131. _delayInfo: Array<string>;
  33132. /** @hidden */
  33133. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33134. /** @hidden */
  33135. _instanceDataStorage: _InstanceDataStorage;
  33136. /** @hidden */
  33137. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33138. private _effectiveMaterial;
  33139. /** @hidden */
  33140. _shouldGenerateFlatShading: boolean;
  33141. /** @hidden */
  33142. _originalBuilderSideOrientation: number;
  33143. /**
  33144. * Use this property to change the original side orientation defined at construction time
  33145. */
  33146. overrideMaterialSideOrientation: Nullable<number>;
  33147. /**
  33148. * Gets the source mesh (the one used to clone this one from)
  33149. */
  33150. get source(): Nullable<Mesh>;
  33151. /**
  33152. * Gets the list of clones of this mesh
  33153. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33154. * Note that useClonedMeshMap=true is the default setting
  33155. */
  33156. get cloneMeshMap(): Nullable<{
  33157. [id: string]: Mesh | undefined;
  33158. }>;
  33159. /**
  33160. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33161. */
  33162. get isUnIndexed(): boolean;
  33163. set isUnIndexed(value: boolean);
  33164. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33165. get worldMatrixInstancedBuffer(): Float32Array;
  33166. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33167. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33168. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33169. /**
  33170. * @constructor
  33171. * @param name The value used by scene.getMeshByName() to do a lookup.
  33172. * @param scene The scene to add this mesh to.
  33173. * @param parent The parent of this mesh, if it has one
  33174. * @param source An optional Mesh from which geometry is shared, cloned.
  33175. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33176. * When false, achieved by calling a clone(), also passing False.
  33177. * This will make creation of children, recursive.
  33178. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33179. */
  33180. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33181. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33182. doNotInstantiate: boolean;
  33183. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33184. /**
  33185. * Gets the class name
  33186. * @returns the string "Mesh".
  33187. */
  33188. getClassName(): string;
  33189. /** @hidden */
  33190. get _isMesh(): boolean;
  33191. /**
  33192. * Returns a description of this mesh
  33193. * @param fullDetails define if full details about this mesh must be used
  33194. * @returns a descriptive string representing this mesh
  33195. */
  33196. toString(fullDetails?: boolean): string;
  33197. /** @hidden */
  33198. _unBindEffect(): void;
  33199. /**
  33200. * Gets a boolean indicating if this mesh has LOD
  33201. */
  33202. get hasLODLevels(): boolean;
  33203. /**
  33204. * Gets the list of MeshLODLevel associated with the current mesh
  33205. * @returns an array of MeshLODLevel
  33206. */
  33207. getLODLevels(): MeshLODLevel[];
  33208. private _sortLODLevels;
  33209. /**
  33210. * Add a mesh as LOD level triggered at the given distance.
  33211. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33212. * @param distance The distance from the center of the object to show this level
  33213. * @param mesh The mesh to be added as LOD level (can be null)
  33214. * @return This mesh (for chaining)
  33215. */
  33216. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33217. /**
  33218. * Returns the LOD level mesh at the passed distance or null if not found.
  33219. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33220. * @param distance The distance from the center of the object to show this level
  33221. * @returns a Mesh or `null`
  33222. */
  33223. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33224. /**
  33225. * Remove a mesh from the LOD array
  33226. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33227. * @param mesh defines the mesh to be removed
  33228. * @return This mesh (for chaining)
  33229. */
  33230. removeLODLevel(mesh: Mesh): Mesh;
  33231. /**
  33232. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33233. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33234. * @param camera defines the camera to use to compute distance
  33235. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33236. * @return This mesh (for chaining)
  33237. */
  33238. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33239. /**
  33240. * Gets the mesh internal Geometry object
  33241. */
  33242. get geometry(): Nullable<Geometry>;
  33243. /**
  33244. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33245. * @returns the total number of vertices
  33246. */
  33247. getTotalVertices(): number;
  33248. /**
  33249. * Returns the content of an associated vertex buffer
  33250. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33251. * - VertexBuffer.PositionKind
  33252. * - VertexBuffer.UVKind
  33253. * - VertexBuffer.UV2Kind
  33254. * - VertexBuffer.UV3Kind
  33255. * - VertexBuffer.UV4Kind
  33256. * - VertexBuffer.UV5Kind
  33257. * - VertexBuffer.UV6Kind
  33258. * - VertexBuffer.ColorKind
  33259. * - VertexBuffer.MatricesIndicesKind
  33260. * - VertexBuffer.MatricesIndicesExtraKind
  33261. * - VertexBuffer.MatricesWeightsKind
  33262. * - VertexBuffer.MatricesWeightsExtraKind
  33263. * @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
  33264. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33265. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33266. */
  33267. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33268. /**
  33269. * Returns the mesh VertexBuffer object from the requested `kind`
  33270. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33271. * - VertexBuffer.PositionKind
  33272. * - VertexBuffer.NormalKind
  33273. * - VertexBuffer.UVKind
  33274. * - VertexBuffer.UV2Kind
  33275. * - VertexBuffer.UV3Kind
  33276. * - VertexBuffer.UV4Kind
  33277. * - VertexBuffer.UV5Kind
  33278. * - VertexBuffer.UV6Kind
  33279. * - VertexBuffer.ColorKind
  33280. * - VertexBuffer.MatricesIndicesKind
  33281. * - VertexBuffer.MatricesIndicesExtraKind
  33282. * - VertexBuffer.MatricesWeightsKind
  33283. * - VertexBuffer.MatricesWeightsExtraKind
  33284. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33285. */
  33286. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33287. /**
  33288. * Tests if a specific vertex buffer is associated with this mesh
  33289. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33290. * - VertexBuffer.PositionKind
  33291. * - VertexBuffer.NormalKind
  33292. * - VertexBuffer.UVKind
  33293. * - VertexBuffer.UV2Kind
  33294. * - VertexBuffer.UV3Kind
  33295. * - VertexBuffer.UV4Kind
  33296. * - VertexBuffer.UV5Kind
  33297. * - VertexBuffer.UV6Kind
  33298. * - VertexBuffer.ColorKind
  33299. * - VertexBuffer.MatricesIndicesKind
  33300. * - VertexBuffer.MatricesIndicesExtraKind
  33301. * - VertexBuffer.MatricesWeightsKind
  33302. * - VertexBuffer.MatricesWeightsExtraKind
  33303. * @returns a boolean
  33304. */
  33305. isVerticesDataPresent(kind: string): boolean;
  33306. /**
  33307. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33308. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33309. * - VertexBuffer.PositionKind
  33310. * - VertexBuffer.UVKind
  33311. * - VertexBuffer.UV2Kind
  33312. * - VertexBuffer.UV3Kind
  33313. * - VertexBuffer.UV4Kind
  33314. * - VertexBuffer.UV5Kind
  33315. * - VertexBuffer.UV6Kind
  33316. * - VertexBuffer.ColorKind
  33317. * - VertexBuffer.MatricesIndicesKind
  33318. * - VertexBuffer.MatricesIndicesExtraKind
  33319. * - VertexBuffer.MatricesWeightsKind
  33320. * - VertexBuffer.MatricesWeightsExtraKind
  33321. * @returns a boolean
  33322. */
  33323. isVertexBufferUpdatable(kind: string): boolean;
  33324. /**
  33325. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33326. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33327. * - VertexBuffer.PositionKind
  33328. * - VertexBuffer.NormalKind
  33329. * - VertexBuffer.UVKind
  33330. * - VertexBuffer.UV2Kind
  33331. * - VertexBuffer.UV3Kind
  33332. * - VertexBuffer.UV4Kind
  33333. * - VertexBuffer.UV5Kind
  33334. * - VertexBuffer.UV6Kind
  33335. * - VertexBuffer.ColorKind
  33336. * - VertexBuffer.MatricesIndicesKind
  33337. * - VertexBuffer.MatricesIndicesExtraKind
  33338. * - VertexBuffer.MatricesWeightsKind
  33339. * - VertexBuffer.MatricesWeightsExtraKind
  33340. * @returns an array of strings
  33341. */
  33342. getVerticesDataKinds(): string[];
  33343. /**
  33344. * Returns a positive integer : the total number of indices in this mesh geometry.
  33345. * @returns the numner of indices or zero if the mesh has no geometry.
  33346. */
  33347. getTotalIndices(): number;
  33348. /**
  33349. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33350. * @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.
  33351. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33352. * @returns the indices array or an empty array if the mesh has no geometry
  33353. */
  33354. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33355. get isBlocked(): boolean;
  33356. /**
  33357. * Determine if the current mesh is ready to be rendered
  33358. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33359. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33360. * @returns true if all associated assets are ready (material, textures, shaders)
  33361. */
  33362. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33363. /**
  33364. * 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.
  33365. */
  33366. get areNormalsFrozen(): boolean;
  33367. /**
  33368. * 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.
  33369. * @returns the current mesh
  33370. */
  33371. freezeNormals(): Mesh;
  33372. /**
  33373. * 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
  33374. * @returns the current mesh
  33375. */
  33376. unfreezeNormals(): Mesh;
  33377. /**
  33378. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33379. */
  33380. set overridenInstanceCount(count: number);
  33381. /** @hidden */
  33382. _preActivate(): Mesh;
  33383. /** @hidden */
  33384. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33385. /** @hidden */
  33386. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33387. protected _afterComputeWorldMatrix(): void;
  33388. /** @hidden */
  33389. _postActivate(): void;
  33390. /**
  33391. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33392. * This means the mesh underlying bounding box and sphere are recomputed.
  33393. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33394. * @returns the current mesh
  33395. */
  33396. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33397. /** @hidden */
  33398. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33399. /**
  33400. * This function will subdivide the mesh into multiple submeshes
  33401. * @param count defines the expected number of submeshes
  33402. */
  33403. subdivide(count: number): void;
  33404. /**
  33405. * Copy a FloatArray into a specific associated vertex buffer
  33406. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33407. * - VertexBuffer.PositionKind
  33408. * - VertexBuffer.UVKind
  33409. * - VertexBuffer.UV2Kind
  33410. * - VertexBuffer.UV3Kind
  33411. * - VertexBuffer.UV4Kind
  33412. * - VertexBuffer.UV5Kind
  33413. * - VertexBuffer.UV6Kind
  33414. * - VertexBuffer.ColorKind
  33415. * - VertexBuffer.MatricesIndicesKind
  33416. * - VertexBuffer.MatricesIndicesExtraKind
  33417. * - VertexBuffer.MatricesWeightsKind
  33418. * - VertexBuffer.MatricesWeightsExtraKind
  33419. * @param data defines the data source
  33420. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33421. * @param stride defines the data stride size (can be null)
  33422. * @returns the current mesh
  33423. */
  33424. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33425. /**
  33426. * Delete a vertex buffer associated with this mesh
  33427. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33428. * - VertexBuffer.PositionKind
  33429. * - VertexBuffer.UVKind
  33430. * - VertexBuffer.UV2Kind
  33431. * - VertexBuffer.UV3Kind
  33432. * - VertexBuffer.UV4Kind
  33433. * - VertexBuffer.UV5Kind
  33434. * - VertexBuffer.UV6Kind
  33435. * - VertexBuffer.ColorKind
  33436. * - VertexBuffer.MatricesIndicesKind
  33437. * - VertexBuffer.MatricesIndicesExtraKind
  33438. * - VertexBuffer.MatricesWeightsKind
  33439. * - VertexBuffer.MatricesWeightsExtraKind
  33440. */
  33441. removeVerticesData(kind: string): void;
  33442. /**
  33443. * Flags an associated vertex buffer as updatable
  33444. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33445. * - VertexBuffer.PositionKind
  33446. * - VertexBuffer.UVKind
  33447. * - VertexBuffer.UV2Kind
  33448. * - VertexBuffer.UV3Kind
  33449. * - VertexBuffer.UV4Kind
  33450. * - VertexBuffer.UV5Kind
  33451. * - VertexBuffer.UV6Kind
  33452. * - VertexBuffer.ColorKind
  33453. * - VertexBuffer.MatricesIndicesKind
  33454. * - VertexBuffer.MatricesIndicesExtraKind
  33455. * - VertexBuffer.MatricesWeightsKind
  33456. * - VertexBuffer.MatricesWeightsExtraKind
  33457. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33458. */
  33459. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33460. /**
  33461. * Sets the mesh global Vertex Buffer
  33462. * @param buffer defines the buffer to use
  33463. * @returns the current mesh
  33464. */
  33465. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33466. /**
  33467. * Update a specific associated vertex buffer
  33468. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33469. * - VertexBuffer.PositionKind
  33470. * - VertexBuffer.UVKind
  33471. * - VertexBuffer.UV2Kind
  33472. * - VertexBuffer.UV3Kind
  33473. * - VertexBuffer.UV4Kind
  33474. * - VertexBuffer.UV5Kind
  33475. * - VertexBuffer.UV6Kind
  33476. * - VertexBuffer.ColorKind
  33477. * - VertexBuffer.MatricesIndicesKind
  33478. * - VertexBuffer.MatricesIndicesExtraKind
  33479. * - VertexBuffer.MatricesWeightsKind
  33480. * - VertexBuffer.MatricesWeightsExtraKind
  33481. * @param data defines the data source
  33482. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33483. * @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)
  33484. * @returns the current mesh
  33485. */
  33486. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33487. /**
  33488. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33489. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33490. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33491. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33492. * @returns the current mesh
  33493. */
  33494. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33495. /**
  33496. * Creates a un-shared specific occurence of the geometry for the mesh.
  33497. * @returns the current mesh
  33498. */
  33499. makeGeometryUnique(): Mesh;
  33500. /**
  33501. * Set the index buffer of this mesh
  33502. * @param indices defines the source data
  33503. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33504. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33505. * @returns the current mesh
  33506. */
  33507. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33508. /**
  33509. * Update the current index buffer
  33510. * @param indices defines the source data
  33511. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33512. * @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)
  33513. * @returns the current mesh
  33514. */
  33515. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33516. /**
  33517. * Invert the geometry to move from a right handed system to a left handed one.
  33518. * @returns the current mesh
  33519. */
  33520. toLeftHanded(): Mesh;
  33521. /** @hidden */
  33522. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33523. /** @hidden */
  33524. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33525. /**
  33526. * Registers for this mesh a javascript function called just before the rendering process
  33527. * @param func defines the function to call before rendering this mesh
  33528. * @returns the current mesh
  33529. */
  33530. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33531. /**
  33532. * Disposes a previously registered javascript function called before the rendering
  33533. * @param func defines the function to remove
  33534. * @returns the current mesh
  33535. */
  33536. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33537. /**
  33538. * Registers for this mesh a javascript function called just after the rendering is complete
  33539. * @param func defines the function to call after rendering this mesh
  33540. * @returns the current mesh
  33541. */
  33542. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33543. /**
  33544. * Disposes a previously registered javascript function called after the rendering.
  33545. * @param func defines the function to remove
  33546. * @returns the current mesh
  33547. */
  33548. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33549. /** @hidden */
  33550. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33551. /** @hidden */
  33552. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33553. /** @hidden */
  33554. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33555. /** @hidden */
  33556. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33557. /** @hidden */
  33558. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33559. /** @hidden */
  33560. _rebuild(): void;
  33561. /** @hidden */
  33562. _freeze(): void;
  33563. /** @hidden */
  33564. _unFreeze(): void;
  33565. /**
  33566. * 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
  33567. * @param subMesh defines the subMesh to render
  33568. * @param enableAlphaMode defines if alpha mode can be changed
  33569. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33570. * @returns the current mesh
  33571. */
  33572. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33573. private _onBeforeDraw;
  33574. /**
  33575. * Renormalize the mesh and patch it up if there are no weights
  33576. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33577. * However in the case of zero weights then we set just a single influence to 1.
  33578. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33579. */
  33580. cleanMatrixWeights(): void;
  33581. private normalizeSkinFourWeights;
  33582. private normalizeSkinWeightsAndExtra;
  33583. /**
  33584. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33585. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33586. * the user know there was an issue with importing the mesh
  33587. * @returns a validation object with skinned, valid and report string
  33588. */
  33589. validateSkinning(): {
  33590. skinned: boolean;
  33591. valid: boolean;
  33592. report: string;
  33593. };
  33594. /** @hidden */
  33595. _checkDelayState(): Mesh;
  33596. private _queueLoad;
  33597. /**
  33598. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33599. * A mesh is in the frustum if its bounding box intersects the frustum
  33600. * @param frustumPlanes defines the frustum to test
  33601. * @returns true if the mesh is in the frustum planes
  33602. */
  33603. isInFrustum(frustumPlanes: Plane[]): boolean;
  33604. /**
  33605. * Sets the mesh material by the material or multiMaterial `id` property
  33606. * @param id is a string identifying the material or the multiMaterial
  33607. * @returns the current mesh
  33608. */
  33609. setMaterialByID(id: string): Mesh;
  33610. /**
  33611. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33612. * @returns an array of IAnimatable
  33613. */
  33614. getAnimatables(): IAnimatable[];
  33615. /**
  33616. * Modifies the mesh geometry according to the passed transformation matrix.
  33617. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33618. * The mesh normals are modified using the same transformation.
  33619. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33620. * @param transform defines the transform matrix to use
  33621. * @see https://doc.babylonjs.com/resources/baking_transformations
  33622. * @returns the current mesh
  33623. */
  33624. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33625. /**
  33626. * Modifies the mesh geometry according to its own current World Matrix.
  33627. * The mesh World Matrix is then reset.
  33628. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33629. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33630. * @see https://doc.babylonjs.com/resources/baking_transformations
  33631. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33632. * @returns the current mesh
  33633. */
  33634. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33635. /** @hidden */
  33636. get _positions(): Nullable<Vector3[]>;
  33637. /** @hidden */
  33638. _resetPointsArrayCache(): Mesh;
  33639. /** @hidden */
  33640. _generatePointsArray(): boolean;
  33641. /**
  33642. * Returns a new Mesh object generated from the current mesh properties.
  33643. * This method must not get confused with createInstance()
  33644. * @param name is a string, the name given to the new mesh
  33645. * @param newParent can be any Node object (default `null`)
  33646. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33647. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33648. * @returns a new mesh
  33649. */
  33650. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33651. /**
  33652. * Releases resources associated with this mesh.
  33653. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33654. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33655. */
  33656. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33657. /** @hidden */
  33658. _disposeInstanceSpecificData(): void;
  33659. /** @hidden */
  33660. _disposeThinInstanceSpecificData(): void;
  33661. /**
  33662. * Modifies the mesh geometry according to a displacement map.
  33663. * 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.
  33664. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33665. * @param url is a string, the URL from the image file is to be downloaded.
  33666. * @param minHeight is the lower limit of the displacement.
  33667. * @param maxHeight is the upper limit of the displacement.
  33668. * @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.
  33669. * @param uvOffset is an optional vector2 used to offset UV.
  33670. * @param uvScale is an optional vector2 used to scale UV.
  33671. * @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.
  33672. * @returns the Mesh.
  33673. */
  33674. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33675. /**
  33676. * Modifies the mesh geometry according to a displacementMap buffer.
  33677. * 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.
  33678. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33679. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33680. * @param heightMapWidth is the width of the buffer image.
  33681. * @param heightMapHeight is the height of the buffer image.
  33682. * @param minHeight is the lower limit of the displacement.
  33683. * @param maxHeight is the upper limit of the displacement.
  33684. * @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.
  33685. * @param uvOffset is an optional vector2 used to offset UV.
  33686. * @param uvScale is an optional vector2 used to scale UV.
  33687. * @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.
  33688. * @returns the Mesh.
  33689. */
  33690. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33691. /**
  33692. * Modify the mesh to get a flat shading rendering.
  33693. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33694. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33695. * @returns current mesh
  33696. */
  33697. convertToFlatShadedMesh(): Mesh;
  33698. /**
  33699. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33700. * In other words, more vertices, no more indices and a single bigger VBO.
  33701. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33702. * @returns current mesh
  33703. */
  33704. convertToUnIndexedMesh(): Mesh;
  33705. /**
  33706. * Inverses facet orientations.
  33707. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33708. * @param flipNormals will also inverts the normals
  33709. * @returns current mesh
  33710. */
  33711. flipFaces(flipNormals?: boolean): Mesh;
  33712. /**
  33713. * Increase the number of facets and hence vertices in a mesh
  33714. * Vertex normals are interpolated from existing vertex normals
  33715. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33716. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33717. */
  33718. increaseVertices(numberPerEdge: number): void;
  33719. /**
  33720. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33721. * This will undo any application of covertToFlatShadedMesh
  33722. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33723. */
  33724. forceSharedVertices(): void;
  33725. /** @hidden */
  33726. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33727. /** @hidden */
  33728. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33729. /**
  33730. * Creates a new InstancedMesh object from the mesh model.
  33731. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33732. * @param name defines the name of the new instance
  33733. * @returns a new InstancedMesh
  33734. */
  33735. createInstance(name: string): InstancedMesh;
  33736. /**
  33737. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33738. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33739. * @returns the current mesh
  33740. */
  33741. synchronizeInstances(): Mesh;
  33742. /**
  33743. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33744. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33745. * This should be used together with the simplification to avoid disappearing triangles.
  33746. * @param successCallback an optional success callback to be called after the optimization finished.
  33747. * @returns the current mesh
  33748. */
  33749. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33750. /**
  33751. * Serialize current mesh
  33752. * @param serializationObject defines the object which will receive the serialization data
  33753. */
  33754. serialize(serializationObject: any): void;
  33755. /** @hidden */
  33756. _syncGeometryWithMorphTargetManager(): void;
  33757. /** @hidden */
  33758. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33759. /**
  33760. * Returns a new Mesh object parsed from the source provided.
  33761. * @param parsedMesh is the source
  33762. * @param scene defines the hosting scene
  33763. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33764. * @returns a new Mesh
  33765. */
  33766. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33767. /**
  33768. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33769. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33770. * @param name defines the name of the mesh to create
  33771. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33772. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33773. * @param closePath creates a seam between the first and the last points of each path of the path array
  33774. * @param offset is taken in account only if the `pathArray` is containing a single path
  33775. * @param scene defines the hosting scene
  33776. * @param updatable defines if the mesh must be flagged as updatable
  33777. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33778. * @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)
  33779. * @returns a new Mesh
  33780. */
  33781. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33782. /**
  33783. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33784. * @param name defines the name of the mesh to create
  33785. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33786. * @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
  33787. * @param scene defines the hosting scene
  33788. * @param updatable defines if the mesh must be flagged as updatable
  33789. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33790. * @returns a new Mesh
  33791. */
  33792. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33793. /**
  33794. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33795. * @param name defines the name of the mesh to create
  33796. * @param size sets the size (float) of each box side (default 1)
  33797. * @param scene defines the hosting scene
  33798. * @param updatable defines if the mesh must be flagged as updatable
  33799. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33800. * @returns a new Mesh
  33801. */
  33802. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33803. /**
  33804. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33805. * @param name defines the name of the mesh to create
  33806. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33807. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33808. * @param scene defines the hosting scene
  33809. * @param updatable defines if the mesh must be flagged as updatable
  33810. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33811. * @returns a new Mesh
  33812. */
  33813. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33814. /**
  33815. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33816. * @param name defines the name of the mesh to create
  33817. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33818. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33819. * @param scene defines the hosting scene
  33820. * @returns a new Mesh
  33821. */
  33822. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33823. /**
  33824. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  33827. * @param diameterTop set the top cap diameter (floats, default 1)
  33828. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33829. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33830. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33831. * @param scene defines the hosting scene
  33832. * @param updatable defines if the mesh must be flagged as updatable
  33833. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33834. * @returns a new Mesh
  33835. */
  33836. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33837. /**
  33838. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33839. * @param name defines the name of the mesh to create
  33840. * @param diameter sets the diameter size (float) of the torus (default 1)
  33841. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33842. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33843. * @param scene defines the hosting scene
  33844. * @param updatable defines if the mesh must be flagged as updatable
  33845. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33846. * @returns a new Mesh
  33847. */
  33848. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33849. /**
  33850. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33851. * @param name defines the name of the mesh to create
  33852. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33853. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33854. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33855. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33856. * @param p the number of windings on X axis (positive integers, default 2)
  33857. * @param q the number of windings on Y axis (positive integers, default 3)
  33858. * @param scene defines the hosting scene
  33859. * @param updatable defines if the mesh must be flagged as updatable
  33860. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33861. * @returns a new Mesh
  33862. */
  33863. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33864. /**
  33865. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33866. * @param name defines the name of the mesh to create
  33867. * @param points is an array successive Vector3
  33868. * @param scene defines the hosting scene
  33869. * @param updatable defines if the mesh must be flagged as updatable
  33870. * @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).
  33871. * @returns a new Mesh
  33872. */
  33873. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33874. /**
  33875. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33876. * @param name defines the name of the mesh to create
  33877. * @param points is an array successive Vector3
  33878. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33879. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33880. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33881. * @param scene defines the hosting scene
  33882. * @param updatable defines if the mesh must be flagged as updatable
  33883. * @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)
  33884. * @returns a new Mesh
  33885. */
  33886. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33887. /**
  33888. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33889. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33890. * 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.
  33891. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33892. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33893. * Remember you can only change the shape positions, not their number when updating a polygon.
  33894. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33895. * @param name defines the name of the mesh to create
  33896. * @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
  33897. * @param scene defines the hosting scene
  33898. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33899. * @param updatable defines if the mesh must be flagged as updatable
  33900. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33901. * @param earcutInjection can be used to inject your own earcut reference
  33902. * @returns a new Mesh
  33903. */
  33904. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33905. /**
  33906. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33908. * @param name defines the name of the mesh to create
  33909. * @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
  33910. * @param depth defines the height of extrusion
  33911. * @param scene defines the hosting scene
  33912. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33913. * @param updatable defines if the mesh must be flagged as updatable
  33914. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33915. * @param earcutInjection can be used to inject your own earcut reference
  33916. * @returns a new Mesh
  33917. */
  33918. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33919. /**
  33920. * Creates an extruded shape mesh.
  33921. * 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
  33922. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33924. * @param name defines the name of the mesh to create
  33925. * @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
  33926. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33927. * @param scale is the value to scale the shape
  33928. * @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
  33929. * @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
  33930. * @param scene defines the hosting scene
  33931. * @param updatable defines if the mesh must be flagged as updatable
  33932. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33933. * @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)
  33934. * @returns a new Mesh
  33935. */
  33936. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33937. /**
  33938. * Creates an custom extruded shape mesh.
  33939. * The custom extrusion is a parametric shape.
  33940. * It has no predefined shape. Its final shape will depend on the input parameters.
  33941. * Please consider using the same method from the MeshBuilder class instead
  33942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33943. * @param name defines the name of the mesh to create
  33944. * @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
  33945. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33946. * @param scaleFunction is a custom Javascript function called on each path point
  33947. * @param rotationFunction is a custom Javascript function called on each path point
  33948. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33949. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33950. * @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
  33951. * @param scene defines the hosting scene
  33952. * @param updatable defines if the mesh must be flagged as updatable
  33953. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33954. * @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)
  33955. * @returns a new Mesh
  33956. */
  33957. 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;
  33958. /**
  33959. * Creates lathe mesh.
  33960. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33961. * Please consider using the same method from the MeshBuilder class instead
  33962. * @param name defines the name of the mesh to create
  33963. * @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
  33964. * @param radius is the radius value of the lathe
  33965. * @param tessellation is the side number of the lathe.
  33966. * @param scene defines the hosting scene
  33967. * @param updatable defines if the mesh must be flagged as updatable
  33968. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33969. * @returns a new Mesh
  33970. */
  33971. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33972. /**
  33973. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33974. * @param name defines the name of the mesh to create
  33975. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33976. * @param scene defines the hosting scene
  33977. * @param updatable defines if the mesh must be flagged as updatable
  33978. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33979. * @returns a new Mesh
  33980. */
  33981. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33982. /**
  33983. * Creates a ground mesh.
  33984. * Please consider using the same method from the MeshBuilder class instead
  33985. * @param name defines the name of the mesh to create
  33986. * @param width set the width of the ground
  33987. * @param height set the height of the ground
  33988. * @param subdivisions sets the number of subdivisions per side
  33989. * @param scene defines the hosting scene
  33990. * @param updatable defines if the mesh must be flagged as updatable
  33991. * @returns a new Mesh
  33992. */
  33993. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33994. /**
  33995. * Creates a tiled ground mesh.
  33996. * Please consider using the same method from the MeshBuilder class instead
  33997. * @param name defines the name of the mesh to create
  33998. * @param xmin set the ground minimum X coordinate
  33999. * @param zmin set the ground minimum Y coordinate
  34000. * @param xmax set the ground maximum X coordinate
  34001. * @param zmax set the ground maximum Z coordinate
  34002. * @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
  34003. * @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
  34004. * @param scene defines the hosting scene
  34005. * @param updatable defines if the mesh must be flagged as updatable
  34006. * @returns a new Mesh
  34007. */
  34008. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34009. w: number;
  34010. h: number;
  34011. }, precision: {
  34012. w: number;
  34013. h: number;
  34014. }, scene: Scene, updatable?: boolean): Mesh;
  34015. /**
  34016. * Creates a ground mesh from a height map.
  34017. * Please consider using the same method from the MeshBuilder class instead
  34018. * @see https://doc.babylonjs.com/babylon101/height_map
  34019. * @param name defines the name of the mesh to create
  34020. * @param url sets the URL of the height map image resource
  34021. * @param width set the ground width size
  34022. * @param height set the ground height size
  34023. * @param subdivisions sets the number of subdivision per side
  34024. * @param minHeight is the minimum altitude on the ground
  34025. * @param maxHeight is the maximum altitude on the ground
  34026. * @param scene defines the hosting scene
  34027. * @param updatable defines if the mesh must be flagged as updatable
  34028. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34029. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34030. * @returns a new Mesh
  34031. */
  34032. 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;
  34033. /**
  34034. * Creates a tube mesh.
  34035. * The tube is a parametric shape.
  34036. * It has no predefined shape. Its final shape will depend on the input parameters.
  34037. * Please consider using the same method from the MeshBuilder class instead
  34038. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34039. * @param name defines the name of the mesh to create
  34040. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34041. * @param radius sets the tube radius size
  34042. * @param tessellation is the number of sides on the tubular surface
  34043. * @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
  34044. * @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
  34045. * @param scene defines the hosting scene
  34046. * @param updatable defines if the mesh must be flagged as updatable
  34047. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34048. * @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)
  34049. * @returns a new Mesh
  34050. */
  34051. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34052. (i: number, distance: number): number;
  34053. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34054. /**
  34055. * Creates a polyhedron mesh.
  34056. * Please consider using the same method from the MeshBuilder class instead.
  34057. * * 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
  34058. * * The parameter `size` (positive float, default 1) sets the polygon size
  34059. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34060. * * 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`
  34061. * * 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
  34062. * * 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)`)
  34063. * * 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
  34064. * * 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
  34065. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34066. * * 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
  34067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34068. * @param name defines the name of the mesh to create
  34069. * @param options defines the options used to create the mesh
  34070. * @param scene defines the hosting scene
  34071. * @returns a new Mesh
  34072. */
  34073. static CreatePolyhedron(name: string, options: {
  34074. type?: number;
  34075. size?: number;
  34076. sizeX?: number;
  34077. sizeY?: number;
  34078. sizeZ?: number;
  34079. custom?: any;
  34080. faceUV?: Vector4[];
  34081. faceColors?: Color4[];
  34082. updatable?: boolean;
  34083. sideOrientation?: number;
  34084. }, scene: Scene): Mesh;
  34085. /**
  34086. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34087. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34088. * * 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`)
  34089. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34090. * * 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
  34091. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34092. * * 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
  34093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34094. * @param name defines the name of the mesh
  34095. * @param options defines the options used to create the mesh
  34096. * @param scene defines the hosting scene
  34097. * @returns a new Mesh
  34098. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34099. */
  34100. static CreateIcoSphere(name: string, options: {
  34101. radius?: number;
  34102. flat?: boolean;
  34103. subdivisions?: number;
  34104. sideOrientation?: number;
  34105. updatable?: boolean;
  34106. }, scene: Scene): Mesh;
  34107. /**
  34108. * Creates a decal mesh.
  34109. * Please consider using the same method from the MeshBuilder class instead.
  34110. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34111. * @param name defines the name of the mesh
  34112. * @param sourceMesh defines the mesh receiving the decal
  34113. * @param position sets the position of the decal in world coordinates
  34114. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34115. * @param size sets the decal scaling
  34116. * @param angle sets the angle to rotate the decal
  34117. * @returns a new Mesh
  34118. */
  34119. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34120. /** Creates a Capsule Mesh
  34121. * @param name defines the name of the mesh.
  34122. * @param options the constructors options used to shape the mesh.
  34123. * @param scene defines the scene the mesh is scoped to.
  34124. * @returns the capsule mesh
  34125. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34126. */
  34127. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34128. /**
  34129. * Prepare internal position array for software CPU skinning
  34130. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34131. */
  34132. setPositionsForCPUSkinning(): Float32Array;
  34133. /**
  34134. * Prepare internal normal array for software CPU skinning
  34135. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34136. */
  34137. setNormalsForCPUSkinning(): Float32Array;
  34138. /**
  34139. * Updates the vertex buffer by applying transformation from the bones
  34140. * @param skeleton defines the skeleton to apply to current mesh
  34141. * @returns the current mesh
  34142. */
  34143. applySkeleton(skeleton: Skeleton): Mesh;
  34144. /**
  34145. * 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
  34146. * @param meshes defines the list of meshes to scan
  34147. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34148. */
  34149. static MinMax(meshes: AbstractMesh[]): {
  34150. min: Vector3;
  34151. max: Vector3;
  34152. };
  34153. /**
  34154. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34155. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34156. * @returns a vector3
  34157. */
  34158. static Center(meshesOrMinMaxVector: {
  34159. min: Vector3;
  34160. max: Vector3;
  34161. } | AbstractMesh[]): Vector3;
  34162. /**
  34163. * Merge the array of meshes into a single mesh for performance reasons.
  34164. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34165. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34166. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34167. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34168. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34169. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34170. * @returns a new mesh
  34171. */
  34172. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34173. /** @hidden */
  34174. addInstance(instance: InstancedMesh): void;
  34175. /** @hidden */
  34176. removeInstance(instance: InstancedMesh): void;
  34177. }
  34178. }
  34179. declare module BABYLON {
  34180. /**
  34181. * The options Interface for creating a Capsule Mesh
  34182. */
  34183. export interface ICreateCapsuleOptions {
  34184. /** The Orientation of the capsule. Default : Vector3.Up() */
  34185. orientation?: Vector3;
  34186. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34187. subdivisions: number;
  34188. /** Number of cylindrical segments on the capsule. */
  34189. tessellation: number;
  34190. /** Height or Length of the capsule. */
  34191. height: number;
  34192. /** Radius of the capsule. */
  34193. radius: number;
  34194. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34195. capSubdivisions: number;
  34196. /** Overwrite for the top radius. */
  34197. radiusTop?: number;
  34198. /** Overwrite for the bottom radius. */
  34199. radiusBottom?: number;
  34200. /** Overwrite for the top capSubdivisions. */
  34201. topCapSubdivisions?: number;
  34202. /** Overwrite for the bottom capSubdivisions. */
  34203. bottomCapSubdivisions?: number;
  34204. }
  34205. /**
  34206. * Class containing static functions to help procedurally build meshes
  34207. */
  34208. export class CapsuleBuilder {
  34209. /**
  34210. * Creates a capsule or a pill mesh
  34211. * @param name defines the name of the mesh
  34212. * @param options The constructors options.
  34213. * @param scene The scene the mesh is scoped to.
  34214. * @returns Capsule Mesh
  34215. */
  34216. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34217. }
  34218. }
  34219. declare module BABYLON {
  34220. /**
  34221. * Define an interface for all classes that will get and set the data on vertices
  34222. */
  34223. export interface IGetSetVerticesData {
  34224. /**
  34225. * Gets a boolean indicating if specific vertex data is present
  34226. * @param kind defines the vertex data kind to use
  34227. * @returns true is data kind is present
  34228. */
  34229. isVerticesDataPresent(kind: string): boolean;
  34230. /**
  34231. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34232. * @param kind defines the data kind (Position, normal, etc...)
  34233. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34234. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34235. * @returns a float array containing vertex data
  34236. */
  34237. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34238. /**
  34239. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34240. * @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.
  34241. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34242. * @returns the indices array or an empty array if the mesh has no geometry
  34243. */
  34244. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34245. /**
  34246. * Set specific vertex data
  34247. * @param kind defines the data kind (Position, normal, etc...)
  34248. * @param data defines the vertex data to use
  34249. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34250. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34251. */
  34252. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34253. /**
  34254. * Update a specific associated vertex buffer
  34255. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34256. * - VertexBuffer.PositionKind
  34257. * - VertexBuffer.UVKind
  34258. * - VertexBuffer.UV2Kind
  34259. * - VertexBuffer.UV3Kind
  34260. * - VertexBuffer.UV4Kind
  34261. * - VertexBuffer.UV5Kind
  34262. * - VertexBuffer.UV6Kind
  34263. * - VertexBuffer.ColorKind
  34264. * - VertexBuffer.MatricesIndicesKind
  34265. * - VertexBuffer.MatricesIndicesExtraKind
  34266. * - VertexBuffer.MatricesWeightsKind
  34267. * - VertexBuffer.MatricesWeightsExtraKind
  34268. * @param data defines the data source
  34269. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34270. * @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)
  34271. */
  34272. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34273. /**
  34274. * Creates a new index buffer
  34275. * @param indices defines the indices to store in the index buffer
  34276. * @param totalVertices defines the total number of vertices (could be null)
  34277. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34278. */
  34279. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34280. }
  34281. /**
  34282. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34283. */
  34284. export class VertexData {
  34285. /**
  34286. * Mesh side orientation : usually the external or front surface
  34287. */
  34288. static readonly FRONTSIDE: number;
  34289. /**
  34290. * Mesh side orientation : usually the internal or back surface
  34291. */
  34292. static readonly BACKSIDE: number;
  34293. /**
  34294. * Mesh side orientation : both internal and external or front and back surfaces
  34295. */
  34296. static readonly DOUBLESIDE: number;
  34297. /**
  34298. * Mesh side orientation : by default, `FRONTSIDE`
  34299. */
  34300. static readonly DEFAULTSIDE: number;
  34301. /**
  34302. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34303. */
  34304. positions: Nullable<FloatArray>;
  34305. /**
  34306. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34307. */
  34308. normals: Nullable<FloatArray>;
  34309. /**
  34310. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34311. */
  34312. tangents: Nullable<FloatArray>;
  34313. /**
  34314. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34315. */
  34316. uvs: Nullable<FloatArray>;
  34317. /**
  34318. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34319. */
  34320. uvs2: Nullable<FloatArray>;
  34321. /**
  34322. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34323. */
  34324. uvs3: Nullable<FloatArray>;
  34325. /**
  34326. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34327. */
  34328. uvs4: Nullable<FloatArray>;
  34329. /**
  34330. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34331. */
  34332. uvs5: Nullable<FloatArray>;
  34333. /**
  34334. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34335. */
  34336. uvs6: Nullable<FloatArray>;
  34337. /**
  34338. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34339. */
  34340. colors: Nullable<FloatArray>;
  34341. /**
  34342. * 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).
  34343. */
  34344. matricesIndices: Nullable<FloatArray>;
  34345. /**
  34346. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34347. */
  34348. matricesWeights: Nullable<FloatArray>;
  34349. /**
  34350. * An array extending the number of possible indices
  34351. */
  34352. matricesIndicesExtra: Nullable<FloatArray>;
  34353. /**
  34354. * An array extending the number of possible weights when the number of indices is extended
  34355. */
  34356. matricesWeightsExtra: Nullable<FloatArray>;
  34357. /**
  34358. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34359. */
  34360. indices: Nullable<IndicesArray>;
  34361. /**
  34362. * Uses the passed data array to set the set the values for the specified kind of data
  34363. * @param data a linear array of floating numbers
  34364. * @param kind the type of data that is being set, eg positions, colors etc
  34365. */
  34366. set(data: FloatArray, kind: string): void;
  34367. /**
  34368. * Associates the vertexData to the passed Mesh.
  34369. * Sets it as updatable or not (default `false`)
  34370. * @param mesh the mesh the vertexData is applied to
  34371. * @param updatable when used and having the value true allows new data to update the vertexData
  34372. * @returns the VertexData
  34373. */
  34374. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34375. /**
  34376. * Associates the vertexData to the passed Geometry.
  34377. * Sets it as updatable or not (default `false`)
  34378. * @param geometry the geometry the vertexData is applied to
  34379. * @param updatable when used and having the value true allows new data to update the vertexData
  34380. * @returns VertexData
  34381. */
  34382. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34383. /**
  34384. * Updates the associated mesh
  34385. * @param mesh the mesh to be updated
  34386. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34387. * @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
  34388. * @returns VertexData
  34389. */
  34390. updateMesh(mesh: Mesh): VertexData;
  34391. /**
  34392. * Updates the associated geometry
  34393. * @param geometry the geometry to be updated
  34394. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34395. * @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
  34396. * @returns VertexData.
  34397. */
  34398. updateGeometry(geometry: Geometry): VertexData;
  34399. private _applyTo;
  34400. private _update;
  34401. /**
  34402. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34403. * @param matrix the transforming matrix
  34404. * @returns the VertexData
  34405. */
  34406. transform(matrix: Matrix): VertexData;
  34407. /**
  34408. * Merges the passed VertexData into the current one
  34409. * @param other the VertexData to be merged into the current one
  34410. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34411. * @returns the modified VertexData
  34412. */
  34413. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34414. private _mergeElement;
  34415. private _validate;
  34416. /**
  34417. * Serializes the VertexData
  34418. * @returns a serialized object
  34419. */
  34420. serialize(): any;
  34421. /**
  34422. * Extracts the vertexData from a mesh
  34423. * @param mesh the mesh from which to extract the VertexData
  34424. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34425. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34426. * @returns the object VertexData associated to the passed mesh
  34427. */
  34428. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34429. /**
  34430. * Extracts the vertexData from the geometry
  34431. * @param geometry the geometry from which to extract the VertexData
  34432. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  34433. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34434. * @returns the object VertexData associated to the passed mesh
  34435. */
  34436. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34437. private static _ExtractFrom;
  34438. /**
  34439. * Creates the VertexData for a Ribbon
  34440. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34441. * * pathArray array of paths, each of which an array of successive Vector3
  34442. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34443. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34444. * * 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
  34445. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34446. * * 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)
  34447. * * 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)
  34448. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34449. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34450. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34451. * @returns the VertexData of the ribbon
  34452. */
  34453. static CreateRibbon(options: {
  34454. pathArray: Vector3[][];
  34455. closeArray?: boolean;
  34456. closePath?: boolean;
  34457. offset?: number;
  34458. sideOrientation?: number;
  34459. frontUVs?: Vector4;
  34460. backUVs?: Vector4;
  34461. invertUV?: boolean;
  34462. uvs?: Vector2[];
  34463. colors?: Color4[];
  34464. }): VertexData;
  34465. /**
  34466. * Creates the VertexData for a box
  34467. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34468. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34469. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34470. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34471. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34472. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34473. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34475. * * 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)
  34476. * * 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)
  34477. * @returns the VertexData of the box
  34478. */
  34479. static CreateBox(options: {
  34480. size?: number;
  34481. width?: number;
  34482. height?: number;
  34483. depth?: number;
  34484. faceUV?: Vector4[];
  34485. faceColors?: Color4[];
  34486. sideOrientation?: number;
  34487. frontUVs?: Vector4;
  34488. backUVs?: Vector4;
  34489. }): VertexData;
  34490. /**
  34491. * Creates the VertexData for a tiled box
  34492. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34493. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34494. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34495. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34497. * @returns the VertexData of the box
  34498. */
  34499. static CreateTiledBox(options: {
  34500. pattern?: number;
  34501. width?: number;
  34502. height?: number;
  34503. depth?: number;
  34504. tileSize?: number;
  34505. tileWidth?: number;
  34506. tileHeight?: number;
  34507. alignHorizontal?: number;
  34508. alignVertical?: number;
  34509. faceUV?: Vector4[];
  34510. faceColors?: Color4[];
  34511. sideOrientation?: number;
  34512. }): VertexData;
  34513. /**
  34514. * Creates the VertexData for a tiled plane
  34515. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34516. * * pattern a limited pattern arrangement depending on the number
  34517. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34518. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34519. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34521. * * 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)
  34522. * * 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)
  34523. * @returns the VertexData of the tiled plane
  34524. */
  34525. static CreateTiledPlane(options: {
  34526. pattern?: number;
  34527. tileSize?: number;
  34528. tileWidth?: number;
  34529. tileHeight?: number;
  34530. size?: number;
  34531. width?: number;
  34532. height?: number;
  34533. alignHorizontal?: number;
  34534. alignVertical?: number;
  34535. sideOrientation?: number;
  34536. frontUVs?: Vector4;
  34537. backUVs?: Vector4;
  34538. }): VertexData;
  34539. /**
  34540. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34541. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34542. * * segments sets the number of horizontal strips optional, default 32
  34543. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34544. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34545. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34546. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34547. * * 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
  34548. * * 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
  34549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34550. * * 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)
  34551. * * 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)
  34552. * @returns the VertexData of the ellipsoid
  34553. */
  34554. static CreateSphere(options: {
  34555. segments?: number;
  34556. diameter?: number;
  34557. diameterX?: number;
  34558. diameterY?: number;
  34559. diameterZ?: number;
  34560. arc?: number;
  34561. slice?: number;
  34562. sideOrientation?: number;
  34563. frontUVs?: Vector4;
  34564. backUVs?: Vector4;
  34565. }): VertexData;
  34566. /**
  34567. * Creates the VertexData for a cylinder, cone or prism
  34568. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34569. * * height sets the height (y direction) of the cylinder, optional, default 2
  34570. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34571. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34572. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34573. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34574. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34575. * * 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
  34576. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34577. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34578. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34579. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34580. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34581. * * 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)
  34582. * * 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)
  34583. * @returns the VertexData of the cylinder, cone or prism
  34584. */
  34585. static CreateCylinder(options: {
  34586. height?: number;
  34587. diameterTop?: number;
  34588. diameterBottom?: number;
  34589. diameter?: number;
  34590. tessellation?: number;
  34591. subdivisions?: number;
  34592. arc?: number;
  34593. faceColors?: Color4[];
  34594. faceUV?: Vector4[];
  34595. hasRings?: boolean;
  34596. enclose?: boolean;
  34597. sideOrientation?: number;
  34598. frontUVs?: Vector4;
  34599. backUVs?: Vector4;
  34600. }): VertexData;
  34601. /**
  34602. * Creates the VertexData for a torus
  34603. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34604. * * diameter the diameter of the torus, optional default 1
  34605. * * thickness the diameter of the tube forming the torus, optional default 0.5
  34606. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34607. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34608. * * 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)
  34609. * * 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)
  34610. * @returns the VertexData of the torus
  34611. */
  34612. static CreateTorus(options: {
  34613. diameter?: number;
  34614. thickness?: number;
  34615. tessellation?: number;
  34616. sideOrientation?: number;
  34617. frontUVs?: Vector4;
  34618. backUVs?: Vector4;
  34619. }): VertexData;
  34620. /**
  34621. * Creates the VertexData of the LineSystem
  34622. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  34623. * - lines an array of lines, each line being an array of successive Vector3
  34624. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  34625. * @returns the VertexData of the LineSystem
  34626. */
  34627. static CreateLineSystem(options: {
  34628. lines: Vector3[][];
  34629. colors?: Nullable<Color4[][]>;
  34630. }): VertexData;
  34631. /**
  34632. * Create the VertexData for a DashedLines
  34633. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  34634. * - points an array successive Vector3
  34635. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  34636. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  34637. * - dashNb the intended total number of dashes, optional, default 200
  34638. * @returns the VertexData for the DashedLines
  34639. */
  34640. static CreateDashedLines(options: {
  34641. points: Vector3[];
  34642. dashSize?: number;
  34643. gapSize?: number;
  34644. dashNb?: number;
  34645. }): VertexData;
  34646. /**
  34647. * Creates the VertexData for a Ground
  34648. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34649. * - width the width (x direction) of the ground, optional, default 1
  34650. * - height the height (z direction) of the ground, optional, default 1
  34651. * - subdivisions the number of subdivisions per side, optional, default 1
  34652. * @returns the VertexData of the Ground
  34653. */
  34654. static CreateGround(options: {
  34655. width?: number;
  34656. height?: number;
  34657. subdivisions?: number;
  34658. subdivisionsX?: number;
  34659. subdivisionsY?: number;
  34660. }): VertexData;
  34661. /**
  34662. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  34663. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34664. * * xmin the ground minimum X coordinate, optional, default -1
  34665. * * zmin the ground minimum Z coordinate, optional, default -1
  34666. * * xmax the ground maximum X coordinate, optional, default 1
  34667. * * zmax the ground maximum Z coordinate, optional, default 1
  34668. * * 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}
  34669. * * 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}
  34670. * @returns the VertexData of the TiledGround
  34671. */
  34672. static CreateTiledGround(options: {
  34673. xmin: number;
  34674. zmin: number;
  34675. xmax: number;
  34676. zmax: number;
  34677. subdivisions?: {
  34678. w: number;
  34679. h: number;
  34680. };
  34681. precision?: {
  34682. w: number;
  34683. h: number;
  34684. };
  34685. }): VertexData;
  34686. /**
  34687. * Creates the VertexData of the Ground designed from a heightmap
  34688. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  34689. * * width the width (x direction) of the ground
  34690. * * height the height (z direction) of the ground
  34691. * * subdivisions the number of subdivisions per side
  34692. * * minHeight the minimum altitude on the ground, optional, default 0
  34693. * * maxHeight the maximum altitude on the ground, optional default 1
  34694. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  34695. * * buffer the array holding the image color data
  34696. * * bufferWidth the width of image
  34697. * * bufferHeight the height of image
  34698. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  34699. * @returns the VertexData of the Ground designed from a heightmap
  34700. */
  34701. static CreateGroundFromHeightMap(options: {
  34702. width: number;
  34703. height: number;
  34704. subdivisions: number;
  34705. minHeight: number;
  34706. maxHeight: number;
  34707. colorFilter: Color3;
  34708. buffer: Uint8Array;
  34709. bufferWidth: number;
  34710. bufferHeight: number;
  34711. alphaFilter: number;
  34712. }): VertexData;
  34713. /**
  34714. * Creates the VertexData for a Plane
  34715. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  34716. * * size sets the width and height of the plane to the value of size, optional default 1
  34717. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  34718. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  34719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34720. * * 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)
  34721. * * 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)
  34722. * @returns the VertexData of the box
  34723. */
  34724. static CreatePlane(options: {
  34725. size?: number;
  34726. width?: number;
  34727. height?: number;
  34728. sideOrientation?: number;
  34729. frontUVs?: Vector4;
  34730. backUVs?: Vector4;
  34731. }): VertexData;
  34732. /**
  34733. * Creates the VertexData of the Disc or regular Polygon
  34734. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  34735. * * radius the radius of the disc, optional default 0.5
  34736. * * tessellation the number of polygon sides, optional, default 64
  34737. * * 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
  34738. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34739. * * 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)
  34740. * * 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)
  34741. * @returns the VertexData of the box
  34742. */
  34743. static CreateDisc(options: {
  34744. radius?: number;
  34745. tessellation?: number;
  34746. arc?: number;
  34747. sideOrientation?: number;
  34748. frontUVs?: Vector4;
  34749. backUVs?: Vector4;
  34750. }): VertexData;
  34751. /**
  34752. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  34753. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34754. * @param polygon a mesh built from polygonTriangulation.build()
  34755. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34756. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34757. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34758. * @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)
  34759. * @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)
  34760. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34761. * @returns the VertexData of the Polygon
  34762. */
  34763. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34764. /**
  34765. * Creates the VertexData of the IcoSphere
  34766. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34767. * * radius the radius of the IcoSphere, optional default 1
  34768. * * radiusX allows stretching in the x direction, optional, default radius
  34769. * * radiusY allows stretching in the y direction, optional, default radius
  34770. * * radiusZ allows stretching in the z direction, optional, default radius
  34771. * * flat when true creates a flat shaded mesh, optional, default true
  34772. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34773. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34774. * * 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)
  34775. * * 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)
  34776. * @returns the VertexData of the IcoSphere
  34777. */
  34778. static CreateIcoSphere(options: {
  34779. radius?: number;
  34780. radiusX?: number;
  34781. radiusY?: number;
  34782. radiusZ?: number;
  34783. flat?: boolean;
  34784. subdivisions?: number;
  34785. sideOrientation?: number;
  34786. frontUVs?: Vector4;
  34787. backUVs?: Vector4;
  34788. }): VertexData;
  34789. /**
  34790. * Creates the VertexData for a Polyhedron
  34791. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34792. * * type provided types are:
  34793. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34794. * * 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)
  34795. * * size the size of the IcoSphere, optional default 1
  34796. * * sizeX allows stretching in the x direction, optional, default size
  34797. * * sizeY allows stretching in the y direction, optional, default size
  34798. * * sizeZ allows stretching in the z direction, optional, default size
  34799. * * 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
  34800. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34801. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34802. * * flat when true creates a flat shaded mesh, optional, default true
  34803. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34804. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34805. * * 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)
  34806. * * 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)
  34807. * @returns the VertexData of the Polyhedron
  34808. */
  34809. static CreatePolyhedron(options: {
  34810. type?: number;
  34811. size?: number;
  34812. sizeX?: number;
  34813. sizeY?: number;
  34814. sizeZ?: number;
  34815. custom?: any;
  34816. faceUV?: Vector4[];
  34817. faceColors?: Color4[];
  34818. flat?: boolean;
  34819. sideOrientation?: number;
  34820. frontUVs?: Vector4;
  34821. backUVs?: Vector4;
  34822. }): VertexData;
  34823. /**
  34824. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34825. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34826. * @returns the VertexData of the Capsule
  34827. */
  34828. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34829. /**
  34830. * Creates the VertexData for a TorusKnot
  34831. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34832. * * radius the radius of the torus knot, optional, default 2
  34833. * * tube the thickness of the tube, optional, default 0.5
  34834. * * radialSegments the number of sides on each tube segments, optional, default 32
  34835. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34836. * * p the number of windings around the z axis, optional, default 2
  34837. * * q the number of windings around the x axis, optional, default 3
  34838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34839. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34840. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34841. * @returns the VertexData of the Torus Knot
  34842. */
  34843. static CreateTorusKnot(options: {
  34844. radius?: number;
  34845. tube?: number;
  34846. radialSegments?: number;
  34847. tubularSegments?: number;
  34848. p?: number;
  34849. q?: number;
  34850. sideOrientation?: number;
  34851. frontUVs?: Vector4;
  34852. backUVs?: Vector4;
  34853. }): VertexData;
  34854. /**
  34855. * Compute normals for given positions and indices
  34856. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34857. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34858. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34859. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34860. * * facetNormals : optional array of facet normals (vector3)
  34861. * * facetPositions : optional array of facet positions (vector3)
  34862. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34863. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34864. * * bInfo : optional bounding info, required for facetPartitioning computation
  34865. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34866. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34867. * * useRightHandedSystem: optional boolean to for right handed system computation
  34868. * * depthSort : optional boolean to enable the facet depth sort computation
  34869. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34870. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34871. */
  34872. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34873. facetNormals?: any;
  34874. facetPositions?: any;
  34875. facetPartitioning?: any;
  34876. ratio?: number;
  34877. bInfo?: any;
  34878. bbSize?: Vector3;
  34879. subDiv?: any;
  34880. useRightHandedSystem?: boolean;
  34881. depthSort?: boolean;
  34882. distanceTo?: Vector3;
  34883. depthSortedFacets?: any;
  34884. }): void;
  34885. /** @hidden */
  34886. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34887. /**
  34888. * Applies VertexData created from the imported parameters to the geometry
  34889. * @param parsedVertexData the parsed data from an imported file
  34890. * @param geometry the geometry to apply the VertexData to
  34891. */
  34892. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34893. }
  34894. }
  34895. declare module BABYLON {
  34896. /**
  34897. * Class containing static functions to help procedurally build meshes
  34898. */
  34899. export class DiscBuilder {
  34900. /**
  34901. * Creates a plane polygonal mesh. By default, this is a disc
  34902. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34903. * * 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
  34904. * * 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
  34905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34906. * * 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
  34907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34908. * @param name defines the name of the mesh
  34909. * @param options defines the options used to create the mesh
  34910. * @param scene defines the hosting scene
  34911. * @returns the plane polygonal mesh
  34912. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34913. */
  34914. static CreateDisc(name: string, options: {
  34915. radius?: number;
  34916. tessellation?: number;
  34917. arc?: number;
  34918. updatable?: boolean;
  34919. sideOrientation?: number;
  34920. frontUVs?: Vector4;
  34921. backUVs?: Vector4;
  34922. }, scene?: Nullable<Scene>): Mesh;
  34923. }
  34924. }
  34925. declare module BABYLON {
  34926. /**
  34927. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34928. *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.
  34929. * The SPS is also a particle system. It provides some methods to manage the particles.
  34930. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34931. *
  34932. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34933. */
  34934. export class SolidParticleSystem implements IDisposable {
  34935. /**
  34936. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34937. * Example : var p = SPS.particles[i];
  34938. */
  34939. particles: SolidParticle[];
  34940. /**
  34941. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34942. */
  34943. nbParticles: number;
  34944. /**
  34945. * If the particles must ever face the camera (default false). Useful for planar particles.
  34946. */
  34947. billboard: boolean;
  34948. /**
  34949. * Recompute normals when adding a shape
  34950. */
  34951. recomputeNormals: boolean;
  34952. /**
  34953. * This a counter ofr your own usage. It's not set by any SPS functions.
  34954. */
  34955. counter: number;
  34956. /**
  34957. * The SPS name. This name is also given to the underlying mesh.
  34958. */
  34959. name: string;
  34960. /**
  34961. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34962. */
  34963. mesh: Mesh;
  34964. /**
  34965. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34966. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34967. */
  34968. vars: any;
  34969. /**
  34970. * This array is populated when the SPS is set as 'pickable'.
  34971. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34972. * Each element of this array is an object `{idx: int, faceId: int}`.
  34973. * `idx` is the picked particle index in the `SPS.particles` array
  34974. * `faceId` is the picked face index counted within this particle.
  34975. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34976. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34977. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34978. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34979. */
  34980. pickedParticles: {
  34981. idx: number;
  34982. faceId: number;
  34983. }[];
  34984. /**
  34985. * This array is populated when the SPS is set as 'pickable'
  34986. * Each key of this array is a submesh index.
  34987. * Each element of this array is a second array defined like this :
  34988. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34989. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34990. * `idx` is the picked particle index in the `SPS.particles` array
  34991. * `faceId` is the picked face index counted within this particle.
  34992. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34993. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34994. */
  34995. pickedBySubMesh: {
  34996. idx: number;
  34997. faceId: number;
  34998. }[][];
  34999. /**
  35000. * This array is populated when `enableDepthSort` is set to true.
  35001. * Each element of this array is an instance of the class DepthSortedParticle.
  35002. */
  35003. depthSortedParticles: DepthSortedParticle[];
  35004. /**
  35005. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35006. * @hidden
  35007. */
  35008. _bSphereOnly: boolean;
  35009. /**
  35010. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35011. * @hidden
  35012. */
  35013. _bSphereRadiusFactor: number;
  35014. private _scene;
  35015. private _positions;
  35016. private _indices;
  35017. private _normals;
  35018. private _colors;
  35019. private _uvs;
  35020. private _indices32;
  35021. private _positions32;
  35022. private _normals32;
  35023. private _fixedNormal32;
  35024. private _colors32;
  35025. private _uvs32;
  35026. private _index;
  35027. private _updatable;
  35028. private _pickable;
  35029. private _isVisibilityBoxLocked;
  35030. private _alwaysVisible;
  35031. private _depthSort;
  35032. private _expandable;
  35033. private _shapeCounter;
  35034. private _copy;
  35035. private _color;
  35036. private _computeParticleColor;
  35037. private _computeParticleTexture;
  35038. private _computeParticleRotation;
  35039. private _computeParticleVertex;
  35040. private _computeBoundingBox;
  35041. private _depthSortParticles;
  35042. private _camera;
  35043. private _mustUnrotateFixedNormals;
  35044. private _particlesIntersect;
  35045. private _needs32Bits;
  35046. private _isNotBuilt;
  35047. private _lastParticleId;
  35048. private _idxOfId;
  35049. private _multimaterialEnabled;
  35050. private _useModelMaterial;
  35051. private _indicesByMaterial;
  35052. private _materialIndexes;
  35053. private _depthSortFunction;
  35054. private _materialSortFunction;
  35055. private _materials;
  35056. private _multimaterial;
  35057. private _materialIndexesById;
  35058. private _defaultMaterial;
  35059. private _autoUpdateSubMeshes;
  35060. private _tmpVertex;
  35061. /**
  35062. * Creates a SPS (Solid Particle System) object.
  35063. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35064. * @param scene (Scene) is the scene in which the SPS is added.
  35065. * @param options defines the options of the sps e.g.
  35066. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35067. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35068. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35069. * * 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.
  35070. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35071. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35072. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35073. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35074. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35075. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35076. */
  35077. constructor(name: string, scene: Scene, options?: {
  35078. updatable?: boolean;
  35079. isPickable?: boolean;
  35080. enableDepthSort?: boolean;
  35081. particleIntersection?: boolean;
  35082. boundingSphereOnly?: boolean;
  35083. bSphereRadiusFactor?: number;
  35084. expandable?: boolean;
  35085. useModelMaterial?: boolean;
  35086. enableMultiMaterial?: boolean;
  35087. });
  35088. /**
  35089. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35090. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35091. * @returns the created mesh
  35092. */
  35093. buildMesh(): Mesh;
  35094. /**
  35095. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35096. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35097. * Thus the particles generated from `digest()` have their property `position` set yet.
  35098. * @param mesh ( Mesh ) is the mesh to be digested
  35099. * @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
  35100. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35101. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35102. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35103. * @returns the current SPS
  35104. */
  35105. digest(mesh: Mesh, options?: {
  35106. facetNb?: number;
  35107. number?: number;
  35108. delta?: number;
  35109. storage?: [];
  35110. }): SolidParticleSystem;
  35111. /**
  35112. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35113. * @hidden
  35114. */
  35115. private _unrotateFixedNormals;
  35116. /**
  35117. * Resets the temporary working copy particle
  35118. * @hidden
  35119. */
  35120. private _resetCopy;
  35121. /**
  35122. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35123. * @param p the current index in the positions array to be updated
  35124. * @param ind the current index in the indices array
  35125. * @param shape a Vector3 array, the shape geometry
  35126. * @param positions the positions array to be updated
  35127. * @param meshInd the shape indices array
  35128. * @param indices the indices array to be updated
  35129. * @param meshUV the shape uv array
  35130. * @param uvs the uv array to be updated
  35131. * @param meshCol the shape color array
  35132. * @param colors the color array to be updated
  35133. * @param meshNor the shape normals array
  35134. * @param normals the normals array to be updated
  35135. * @param idx the particle index
  35136. * @param idxInShape the particle index in its shape
  35137. * @param options the addShape() method passed options
  35138. * @model the particle model
  35139. * @hidden
  35140. */
  35141. private _meshBuilder;
  35142. /**
  35143. * Returns a shape Vector3 array from positions float array
  35144. * @param positions float array
  35145. * @returns a vector3 array
  35146. * @hidden
  35147. */
  35148. private _posToShape;
  35149. /**
  35150. * Returns a shapeUV array from a float uvs (array deep copy)
  35151. * @param uvs as a float array
  35152. * @returns a shapeUV array
  35153. * @hidden
  35154. */
  35155. private _uvsToShapeUV;
  35156. /**
  35157. * Adds a new particle object in the particles array
  35158. * @param idx particle index in particles array
  35159. * @param id particle id
  35160. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35161. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35162. * @param model particle ModelShape object
  35163. * @param shapeId model shape identifier
  35164. * @param idxInShape index of the particle in the current model
  35165. * @param bInfo model bounding info object
  35166. * @param storage target storage array, if any
  35167. * @hidden
  35168. */
  35169. private _addParticle;
  35170. /**
  35171. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35172. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35173. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35174. * @param nb (positive integer) the number of particles to be created from this model
  35175. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35176. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35177. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35178. * @returns the number of shapes in the system
  35179. */
  35180. addShape(mesh: Mesh, nb: number, options?: {
  35181. positionFunction?: any;
  35182. vertexFunction?: any;
  35183. storage?: [];
  35184. }): number;
  35185. /**
  35186. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35187. * @hidden
  35188. */
  35189. private _rebuildParticle;
  35190. /**
  35191. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35192. * @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.
  35193. * @returns the SPS.
  35194. */
  35195. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35196. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35197. * Returns an array with the removed particles.
  35198. * 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.
  35199. * The SPS can't be empty so at least one particle needs to remain in place.
  35200. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35201. * @param start index of the first particle to remove
  35202. * @param end index of the last particle to remove (included)
  35203. * @returns an array populated with the removed particles
  35204. */
  35205. removeParticles(start: number, end: number): SolidParticle[];
  35206. /**
  35207. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35208. * @param solidParticleArray an array populated with Solid Particles objects
  35209. * @returns the SPS
  35210. */
  35211. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35212. /**
  35213. * Creates a new particle and modifies the SPS mesh geometry :
  35214. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35215. * - calls _addParticle() to populate the particle array
  35216. * factorized code from addShape() and insertParticlesFromArray()
  35217. * @param idx particle index in the particles array
  35218. * @param i particle index in its shape
  35219. * @param modelShape particle ModelShape object
  35220. * @param shape shape vertex array
  35221. * @param meshInd shape indices array
  35222. * @param meshUV shape uv array
  35223. * @param meshCol shape color array
  35224. * @param meshNor shape normals array
  35225. * @param bbInfo shape bounding info
  35226. * @param storage target particle storage
  35227. * @options addShape() passed options
  35228. * @hidden
  35229. */
  35230. private _insertNewParticle;
  35231. /**
  35232. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35233. * This method calls `updateParticle()` for each particle of the SPS.
  35234. * For an animated SPS, it is usually called within the render loop.
  35235. * 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.
  35236. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35237. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35238. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35239. * @returns the SPS.
  35240. */
  35241. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35242. /**
  35243. * Disposes the SPS.
  35244. */
  35245. dispose(): void;
  35246. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35247. * idx is the particle index in the SPS
  35248. * faceId is the picked face index counted within this particle.
  35249. * Returns null if the pickInfo can't identify a picked particle.
  35250. * @param pickingInfo (PickingInfo object)
  35251. * @returns {idx: number, faceId: number} or null
  35252. */
  35253. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35254. idx: number;
  35255. faceId: number;
  35256. }>;
  35257. /**
  35258. * Returns a SolidParticle object from its identifier : particle.id
  35259. * @param id (integer) the particle Id
  35260. * @returns the searched particle or null if not found in the SPS.
  35261. */
  35262. getParticleById(id: number): Nullable<SolidParticle>;
  35263. /**
  35264. * Returns a new array populated with the particles having the passed shapeId.
  35265. * @param shapeId (integer) the shape identifier
  35266. * @returns a new solid particle array
  35267. */
  35268. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35269. /**
  35270. * Populates the passed array "ref" with the particles having the passed shapeId.
  35271. * @param shapeId the shape identifier
  35272. * @returns the SPS
  35273. * @param ref
  35274. */
  35275. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35276. /**
  35277. * Computes the required SubMeshes according the materials assigned to the particles.
  35278. * @returns the solid particle system.
  35279. * Does nothing if called before the SPS mesh is built.
  35280. */
  35281. computeSubMeshes(): SolidParticleSystem;
  35282. /**
  35283. * Sorts the solid particles by material when MultiMaterial is enabled.
  35284. * Updates the indices32 array.
  35285. * Updates the indicesByMaterial array.
  35286. * Updates the mesh indices array.
  35287. * @returns the SPS
  35288. * @hidden
  35289. */
  35290. private _sortParticlesByMaterial;
  35291. /**
  35292. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35293. * @hidden
  35294. */
  35295. private _setMaterialIndexesById;
  35296. /**
  35297. * Returns an array with unique values of Materials from the passed array
  35298. * @param array the material array to be checked and filtered
  35299. * @hidden
  35300. */
  35301. private _filterUniqueMaterialId;
  35302. /**
  35303. * Sets a new Standard Material as _defaultMaterial if not already set.
  35304. * @hidden
  35305. */
  35306. private _setDefaultMaterial;
  35307. /**
  35308. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35309. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35310. * @returns the SPS.
  35311. */
  35312. refreshVisibleSize(): SolidParticleSystem;
  35313. /**
  35314. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35315. * @param size the size (float) of the visibility box
  35316. * note : this doesn't lock the SPS mesh bounding box.
  35317. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35318. */
  35319. setVisibilityBox(size: number): void;
  35320. /**
  35321. * Gets whether the SPS as always visible or not
  35322. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35323. */
  35324. get isAlwaysVisible(): boolean;
  35325. /**
  35326. * Sets the SPS as always visible or not
  35327. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35328. */
  35329. set isAlwaysVisible(val: boolean);
  35330. /**
  35331. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35332. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35333. */
  35334. set isVisibilityBoxLocked(val: boolean);
  35335. /**
  35336. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35337. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35338. */
  35339. get isVisibilityBoxLocked(): boolean;
  35340. /**
  35341. * Tells to `setParticles()` to compute the particle rotations or not.
  35342. * Default value : true. The SPS is faster when it's set to false.
  35343. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35344. */
  35345. set computeParticleRotation(val: boolean);
  35346. /**
  35347. * Tells to `setParticles()` to compute the particle colors or not.
  35348. * Default value : true. The SPS is faster when it's set to false.
  35349. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35350. */
  35351. set computeParticleColor(val: boolean);
  35352. set computeParticleTexture(val: boolean);
  35353. /**
  35354. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35355. * Default value : false. The SPS is faster when it's set to false.
  35356. * Note : the particle custom vertex positions aren't stored values.
  35357. */
  35358. set computeParticleVertex(val: boolean);
  35359. /**
  35360. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35361. */
  35362. set computeBoundingBox(val: boolean);
  35363. /**
  35364. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35365. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35366. * Default : `true`
  35367. */
  35368. set depthSortParticles(val: boolean);
  35369. /**
  35370. * Gets if `setParticles()` computes the particle rotations or not.
  35371. * Default value : true. The SPS is faster when it's set to false.
  35372. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35373. */
  35374. get computeParticleRotation(): boolean;
  35375. /**
  35376. * Gets if `setParticles()` computes the particle colors or not.
  35377. * Default value : true. The SPS is faster when it's set to false.
  35378. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35379. */
  35380. get computeParticleColor(): boolean;
  35381. /**
  35382. * Gets if `setParticles()` computes the particle textures or not.
  35383. * Default value : true. The SPS is faster when it's set to false.
  35384. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35385. */
  35386. get computeParticleTexture(): boolean;
  35387. /**
  35388. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35389. * Default value : false. The SPS is faster when it's set to false.
  35390. * Note : the particle custom vertex positions aren't stored values.
  35391. */
  35392. get computeParticleVertex(): boolean;
  35393. /**
  35394. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35395. */
  35396. get computeBoundingBox(): boolean;
  35397. /**
  35398. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35399. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35400. * Default : `true`
  35401. */
  35402. get depthSortParticles(): boolean;
  35403. /**
  35404. * Gets if the SPS is created as expandable at construction time.
  35405. * Default : `false`
  35406. */
  35407. get expandable(): boolean;
  35408. /**
  35409. * Gets if the SPS supports the Multi Materials
  35410. */
  35411. get multimaterialEnabled(): boolean;
  35412. /**
  35413. * Gets if the SPS uses the model materials for its own multimaterial.
  35414. */
  35415. get useModelMaterial(): boolean;
  35416. /**
  35417. * The SPS used material array.
  35418. */
  35419. get materials(): Material[];
  35420. /**
  35421. * Sets the SPS MultiMaterial from the passed materials.
  35422. * Note : the passed array is internally copied and not used then by reference.
  35423. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35424. */
  35425. setMultiMaterial(materials: Material[]): void;
  35426. /**
  35427. * The SPS computed multimaterial object
  35428. */
  35429. get multimaterial(): MultiMaterial;
  35430. set multimaterial(mm: MultiMaterial);
  35431. /**
  35432. * If the subMeshes must be updated on the next call to setParticles()
  35433. */
  35434. get autoUpdateSubMeshes(): boolean;
  35435. set autoUpdateSubMeshes(val: boolean);
  35436. /**
  35437. * This function does nothing. It may be overwritten to set all the particle first values.
  35438. * The SPS doesn't call this function, you may have to call it by your own.
  35439. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35440. */
  35441. initParticles(): void;
  35442. /**
  35443. * This function does nothing. It may be overwritten to recycle a particle.
  35444. * The SPS doesn't call this function, you may have to call it by your own.
  35445. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35446. * @param particle The particle to recycle
  35447. * @returns the recycled particle
  35448. */
  35449. recycleParticle(particle: SolidParticle): SolidParticle;
  35450. /**
  35451. * Updates a particle : this function should be overwritten by the user.
  35452. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35453. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35454. * @example : just set a particle position or velocity and recycle conditions
  35455. * @param particle The particle to update
  35456. * @returns the updated particle
  35457. */
  35458. updateParticle(particle: SolidParticle): SolidParticle;
  35459. /**
  35460. * Updates a vertex of a particle : it can be overwritten by the user.
  35461. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35462. * @param particle the current particle
  35463. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35464. * @param pt the index of the current vertex in the particle shape
  35465. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35466. * @example : just set a vertex particle position or color
  35467. * @returns the sps
  35468. */
  35469. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35470. /**
  35471. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35472. * This does nothing and may be overwritten by the user.
  35473. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35474. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35475. * @param update the boolean update value actually passed to setParticles()
  35476. */
  35477. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35478. /**
  35479. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35480. * This 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. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35487. }
  35488. }
  35489. declare module BABYLON {
  35490. /**
  35491. * Represents one particle of a solid particle system.
  35492. */
  35493. export class SolidParticle {
  35494. /**
  35495. * particle global index
  35496. */
  35497. idx: number;
  35498. /**
  35499. * particle identifier
  35500. */
  35501. id: number;
  35502. /**
  35503. * The color of the particle
  35504. */
  35505. color: Nullable<Color4>;
  35506. /**
  35507. * The world space position of the particle.
  35508. */
  35509. position: Vector3;
  35510. /**
  35511. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35512. */
  35513. rotation: Vector3;
  35514. /**
  35515. * The world space rotation quaternion of the particle.
  35516. */
  35517. rotationQuaternion: Nullable<Quaternion>;
  35518. /**
  35519. * The scaling of the particle.
  35520. */
  35521. scaling: Vector3;
  35522. /**
  35523. * The uvs of the particle.
  35524. */
  35525. uvs: Vector4;
  35526. /**
  35527. * The current speed of the particle.
  35528. */
  35529. velocity: Vector3;
  35530. /**
  35531. * The pivot point in the particle local space.
  35532. */
  35533. pivot: Vector3;
  35534. /**
  35535. * Must the particle be translated from its pivot point in its local space ?
  35536. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35537. * Default : false
  35538. */
  35539. translateFromPivot: boolean;
  35540. /**
  35541. * Is the particle active or not ?
  35542. */
  35543. alive: boolean;
  35544. /**
  35545. * Is the particle visible or not ?
  35546. */
  35547. isVisible: boolean;
  35548. /**
  35549. * Index of this particle in the global "positions" array (Internal use)
  35550. * @hidden
  35551. */
  35552. _pos: number;
  35553. /**
  35554. * @hidden Index of this particle in the global "indices" array (Internal use)
  35555. */
  35556. _ind: number;
  35557. /**
  35558. * @hidden ModelShape of this particle (Internal use)
  35559. */
  35560. _model: ModelShape;
  35561. /**
  35562. * ModelShape id of this particle
  35563. */
  35564. shapeId: number;
  35565. /**
  35566. * Index of the particle in its shape id
  35567. */
  35568. idxInShape: number;
  35569. /**
  35570. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35571. */
  35572. _modelBoundingInfo: BoundingInfo;
  35573. /**
  35574. * @hidden Particle BoundingInfo object (Internal use)
  35575. */
  35576. _boundingInfo: BoundingInfo;
  35577. /**
  35578. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35579. */
  35580. _sps: SolidParticleSystem;
  35581. /**
  35582. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35583. */
  35584. _stillInvisible: boolean;
  35585. /**
  35586. * @hidden Last computed particle rotation matrix
  35587. */
  35588. _rotationMatrix: number[];
  35589. /**
  35590. * Parent particle Id, if any.
  35591. * Default null.
  35592. */
  35593. parentId: Nullable<number>;
  35594. /**
  35595. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35596. */
  35597. materialIndex: Nullable<number>;
  35598. /**
  35599. * Custom object or properties.
  35600. */
  35601. props: Nullable<any>;
  35602. /**
  35603. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35604. * The possible values are :
  35605. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35606. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35607. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35608. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35609. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35610. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35611. * */
  35612. cullingStrategy: number;
  35613. /**
  35614. * @hidden Internal global position in the SPS.
  35615. */
  35616. _globalPosition: Vector3;
  35617. /**
  35618. * Creates a Solid Particle object.
  35619. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35620. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35621. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35622. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35623. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35624. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35625. * @param shapeId (integer) is the model shape identifier in the SPS.
  35626. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35627. * @param sps defines the sps it is associated to
  35628. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35629. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35630. */
  35631. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35632. /**
  35633. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35634. * @param target the particle target
  35635. * @returns the current particle
  35636. */
  35637. copyToRef(target: SolidParticle): SolidParticle;
  35638. /**
  35639. * Legacy support, changed scale to scaling
  35640. */
  35641. get scale(): Vector3;
  35642. /**
  35643. * Legacy support, changed scale to scaling
  35644. */
  35645. set scale(scale: Vector3);
  35646. /**
  35647. * Legacy support, changed quaternion to rotationQuaternion
  35648. */
  35649. get quaternion(): Nullable<Quaternion>;
  35650. /**
  35651. * Legacy support, changed quaternion to rotationQuaternion
  35652. */
  35653. set quaternion(q: Nullable<Quaternion>);
  35654. /**
  35655. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35656. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35657. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35658. * @returns true if it intersects
  35659. */
  35660. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35661. /**
  35662. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35663. * A particle is in the frustum if its bounding box intersects the frustum
  35664. * @param frustumPlanes defines the frustum to test
  35665. * @returns true if the particle is in the frustum planes
  35666. */
  35667. isInFrustum(frustumPlanes: Plane[]): boolean;
  35668. /**
  35669. * get the rotation matrix of the particle
  35670. * @hidden
  35671. */
  35672. getRotationMatrix(m: Matrix): void;
  35673. }
  35674. /**
  35675. * Represents the shape of the model used by one particle of a solid particle system.
  35676. * SPS internal tool, don't use it manually.
  35677. */
  35678. export class ModelShape {
  35679. /**
  35680. * The shape id
  35681. * @hidden
  35682. */
  35683. shapeID: number;
  35684. /**
  35685. * flat array of model positions (internal use)
  35686. * @hidden
  35687. */
  35688. _shape: Vector3[];
  35689. /**
  35690. * flat array of model UVs (internal use)
  35691. * @hidden
  35692. */
  35693. _shapeUV: number[];
  35694. /**
  35695. * color array of the model
  35696. * @hidden
  35697. */
  35698. _shapeColors: number[];
  35699. /**
  35700. * indices array of the model
  35701. * @hidden
  35702. */
  35703. _indices: number[];
  35704. /**
  35705. * normals array of the model
  35706. * @hidden
  35707. */
  35708. _normals: number[];
  35709. /**
  35710. * length of the shape in the model indices array (internal use)
  35711. * @hidden
  35712. */
  35713. _indicesLength: number;
  35714. /**
  35715. * Custom position function (internal use)
  35716. * @hidden
  35717. */
  35718. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35719. /**
  35720. * Custom vertex function (internal use)
  35721. * @hidden
  35722. */
  35723. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35724. /**
  35725. * Model material (internal use)
  35726. * @hidden
  35727. */
  35728. _material: Nullable<Material>;
  35729. /**
  35730. * 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.
  35731. * SPS internal tool, don't use it manually.
  35732. * @hidden
  35733. */
  35734. 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>);
  35735. }
  35736. /**
  35737. * Represents a Depth Sorted Particle in the solid particle system.
  35738. * @hidden
  35739. */
  35740. export class DepthSortedParticle {
  35741. /**
  35742. * Particle index
  35743. */
  35744. idx: number;
  35745. /**
  35746. * Index of the particle in the "indices" array
  35747. */
  35748. ind: number;
  35749. /**
  35750. * Length of the particle shape in the "indices" array
  35751. */
  35752. indicesLength: number;
  35753. /**
  35754. * Squared distance from the particle to the camera
  35755. */
  35756. sqDistance: number;
  35757. /**
  35758. * Material index when used with MultiMaterials
  35759. */
  35760. materialIndex: number;
  35761. /**
  35762. * Creates a new sorted particle
  35763. * @param materialIndex
  35764. */
  35765. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35766. }
  35767. /**
  35768. * Represents a solid particle vertex
  35769. */
  35770. export class SolidParticleVertex {
  35771. /**
  35772. * Vertex position
  35773. */
  35774. position: Vector3;
  35775. /**
  35776. * Vertex color
  35777. */
  35778. color: Color4;
  35779. /**
  35780. * Vertex UV
  35781. */
  35782. uv: Vector2;
  35783. /**
  35784. * Creates a new solid particle vertex
  35785. */
  35786. constructor();
  35787. /** Vertex x coordinate */
  35788. get x(): number;
  35789. set x(val: number);
  35790. /** Vertex y coordinate */
  35791. get y(): number;
  35792. set y(val: number);
  35793. /** Vertex z coordinate */
  35794. get z(): number;
  35795. set z(val: number);
  35796. }
  35797. }
  35798. declare module BABYLON {
  35799. /**
  35800. * @hidden
  35801. */
  35802. export class _MeshCollisionData {
  35803. _checkCollisions: boolean;
  35804. _collisionMask: number;
  35805. _collisionGroup: number;
  35806. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35807. _collider: Nullable<Collider>;
  35808. _oldPositionForCollisions: Vector3;
  35809. _diffPositionForCollisions: Vector3;
  35810. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35811. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35812. _collisionResponse: boolean;
  35813. }
  35814. }
  35815. declare module BABYLON {
  35816. /** @hidden */
  35817. class _FacetDataStorage {
  35818. facetPositions: Vector3[];
  35819. facetNormals: Vector3[];
  35820. facetPartitioning: number[][];
  35821. facetNb: number;
  35822. partitioningSubdivisions: number;
  35823. partitioningBBoxRatio: number;
  35824. facetDataEnabled: boolean;
  35825. facetParameters: any;
  35826. bbSize: Vector3;
  35827. subDiv: {
  35828. max: number;
  35829. X: number;
  35830. Y: number;
  35831. Z: number;
  35832. };
  35833. facetDepthSort: boolean;
  35834. facetDepthSortEnabled: boolean;
  35835. depthSortedIndices: IndicesArray;
  35836. depthSortedFacets: {
  35837. ind: number;
  35838. sqDistance: number;
  35839. }[];
  35840. facetDepthSortFunction: (f1: {
  35841. ind: number;
  35842. sqDistance: number;
  35843. }, f2: {
  35844. ind: number;
  35845. sqDistance: number;
  35846. }) => number;
  35847. facetDepthSortFrom: Vector3;
  35848. facetDepthSortOrigin: Vector3;
  35849. invertedMatrix: Matrix;
  35850. }
  35851. /**
  35852. * @hidden
  35853. **/
  35854. class _InternalAbstractMeshDataInfo {
  35855. _hasVertexAlpha: boolean;
  35856. _useVertexColors: boolean;
  35857. _numBoneInfluencers: number;
  35858. _applyFog: boolean;
  35859. _receiveShadows: boolean;
  35860. _facetData: _FacetDataStorage;
  35861. _visibility: number;
  35862. _skeleton: Nullable<Skeleton>;
  35863. _layerMask: number;
  35864. _computeBonesUsingShaders: boolean;
  35865. _isActive: boolean;
  35866. _onlyForInstances: boolean;
  35867. _isActiveIntermediate: boolean;
  35868. _onlyForInstancesIntermediate: boolean;
  35869. _actAsRegularMesh: boolean;
  35870. _currentLOD: Nullable<AbstractMesh>;
  35871. _currentLODIsUpToDate: boolean;
  35872. }
  35873. /**
  35874. * Class used to store all common mesh properties
  35875. */
  35876. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35877. /** No occlusion */
  35878. static OCCLUSION_TYPE_NONE: number;
  35879. /** Occlusion set to optimisitic */
  35880. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35881. /** Occlusion set to strict */
  35882. static OCCLUSION_TYPE_STRICT: number;
  35883. /** Use an accurante occlusion algorithm */
  35884. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35885. /** Use a conservative occlusion algorithm */
  35886. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35887. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35888. * Test order :
  35889. * Is the bounding sphere outside the frustum ?
  35890. * If not, are the bounding box vertices outside the frustum ?
  35891. * It not, then the cullable object is in the frustum.
  35892. */
  35893. static readonly CULLINGSTRATEGY_STANDARD: number;
  35894. /** Culling strategy : Bounding Sphere Only.
  35895. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35896. * It's also less accurate than the standard because some not visible objects can still be selected.
  35897. * Test : is the bounding sphere outside the frustum ?
  35898. * If not, then the cullable object is in the frustum.
  35899. */
  35900. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35901. /** Culling strategy : Optimistic Inclusion.
  35902. * This in an inclusion test first, then the standard exclusion test.
  35903. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35904. * 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.
  35905. * Anyway, it's as accurate as the standard strategy.
  35906. * Test :
  35907. * Is the cullable object bounding sphere center in the frustum ?
  35908. * If not, apply the default culling strategy.
  35909. */
  35910. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35911. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35912. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35913. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35914. * 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.
  35915. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35916. * Test :
  35917. * Is the cullable object bounding sphere center in the frustum ?
  35918. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35919. */
  35920. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35921. /**
  35922. * No billboard
  35923. */
  35924. static get BILLBOARDMODE_NONE(): number;
  35925. /** Billboard on X axis */
  35926. static get BILLBOARDMODE_X(): number;
  35927. /** Billboard on Y axis */
  35928. static get BILLBOARDMODE_Y(): number;
  35929. /** Billboard on Z axis */
  35930. static get BILLBOARDMODE_Z(): number;
  35931. /** Billboard on all axes */
  35932. static get BILLBOARDMODE_ALL(): number;
  35933. /** Billboard on using position instead of orientation */
  35934. static get BILLBOARDMODE_USE_POSITION(): number;
  35935. /** @hidden */
  35936. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35937. /**
  35938. * The culling strategy to use to check whether the mesh must be rendered or not.
  35939. * This value can be changed at any time and will be used on the next render mesh selection.
  35940. * The possible values are :
  35941. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35942. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35943. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35944. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35945. * Please read each static variable documentation to get details about the culling process.
  35946. * */
  35947. cullingStrategy: number;
  35948. /**
  35949. * Gets the number of facets in the mesh
  35950. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35951. */
  35952. get facetNb(): number;
  35953. /**
  35954. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35955. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35956. */
  35957. get partitioningSubdivisions(): number;
  35958. set partitioningSubdivisions(nb: number);
  35959. /**
  35960. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35961. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35962. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35963. */
  35964. get partitioningBBoxRatio(): number;
  35965. set partitioningBBoxRatio(ratio: number);
  35966. /**
  35967. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35968. * Works only for updatable meshes.
  35969. * Doesn't work with multi-materials
  35970. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35971. */
  35972. get mustDepthSortFacets(): boolean;
  35973. set mustDepthSortFacets(sort: boolean);
  35974. /**
  35975. * The location (Vector3) where the facet depth sort must be computed from.
  35976. * By default, the active camera position.
  35977. * Used only when facet depth sort is enabled
  35978. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35979. */
  35980. get facetDepthSortFrom(): Vector3;
  35981. set facetDepthSortFrom(location: Vector3);
  35982. /**
  35983. * gets a boolean indicating if facetData is enabled
  35984. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35985. */
  35986. get isFacetDataEnabled(): boolean;
  35987. /** @hidden */
  35988. _updateNonUniformScalingState(value: boolean): boolean;
  35989. /**
  35990. * An event triggered when this mesh collides with another one
  35991. */
  35992. onCollideObservable: Observable<AbstractMesh>;
  35993. /** Set a function to call when this mesh collides with another one */
  35994. set onCollide(callback: () => void);
  35995. /**
  35996. * An event triggered when the collision's position changes
  35997. */
  35998. onCollisionPositionChangeObservable: Observable<Vector3>;
  35999. /** Set a function to call when the collision's position changes */
  36000. set onCollisionPositionChange(callback: () => void);
  36001. /**
  36002. * An event triggered when material is changed
  36003. */
  36004. onMaterialChangedObservable: Observable<AbstractMesh>;
  36005. /**
  36006. * Gets or sets the orientation for POV movement & rotation
  36007. */
  36008. definedFacingForward: boolean;
  36009. /** @hidden */
  36010. _occlusionQuery: Nullable<WebGLQuery>;
  36011. /** @hidden */
  36012. _renderingGroup: Nullable<RenderingGroup>;
  36013. /**
  36014. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36015. */
  36016. get visibility(): number;
  36017. /**
  36018. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36019. */
  36020. set visibility(value: number);
  36021. /** Gets or sets the alpha index used to sort transparent meshes
  36022. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36023. */
  36024. alphaIndex: number;
  36025. /**
  36026. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36027. */
  36028. isVisible: boolean;
  36029. /**
  36030. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36031. */
  36032. isPickable: boolean;
  36033. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36034. showSubMeshesBoundingBox: boolean;
  36035. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36036. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36037. */
  36038. isBlocker: boolean;
  36039. /**
  36040. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36041. */
  36042. enablePointerMoveEvents: boolean;
  36043. private _renderingGroupId;
  36044. /**
  36045. * Specifies the rendering group id for this mesh (0 by default)
  36046. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36047. */
  36048. get renderingGroupId(): number;
  36049. set renderingGroupId(value: number);
  36050. private _material;
  36051. /** Gets or sets current material */
  36052. get material(): Nullable<Material>;
  36053. set material(value: Nullable<Material>);
  36054. /**
  36055. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36056. * @see https://doc.babylonjs.com/babylon101/shadows
  36057. */
  36058. get receiveShadows(): boolean;
  36059. set receiveShadows(value: boolean);
  36060. /** Defines color to use when rendering outline */
  36061. outlineColor: Color3;
  36062. /** Define width to use when rendering outline */
  36063. outlineWidth: number;
  36064. /** Defines color to use when rendering overlay */
  36065. overlayColor: Color3;
  36066. /** Defines alpha to use when rendering overlay */
  36067. overlayAlpha: number;
  36068. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36069. get hasVertexAlpha(): boolean;
  36070. set hasVertexAlpha(value: boolean);
  36071. /** 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) */
  36072. get useVertexColors(): boolean;
  36073. set useVertexColors(value: boolean);
  36074. /**
  36075. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36076. */
  36077. get computeBonesUsingShaders(): boolean;
  36078. set computeBonesUsingShaders(value: boolean);
  36079. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36080. get numBoneInfluencers(): number;
  36081. set numBoneInfluencers(value: number);
  36082. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36083. get applyFog(): boolean;
  36084. set applyFog(value: boolean);
  36085. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36086. useOctreeForRenderingSelection: boolean;
  36087. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36088. useOctreeForPicking: boolean;
  36089. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36090. useOctreeForCollisions: boolean;
  36091. /**
  36092. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36093. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36094. */
  36095. get layerMask(): number;
  36096. set layerMask(value: number);
  36097. /**
  36098. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36099. */
  36100. alwaysSelectAsActiveMesh: boolean;
  36101. /**
  36102. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36103. */
  36104. doNotSyncBoundingInfo: boolean;
  36105. /**
  36106. * Gets or sets the current action manager
  36107. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36108. */
  36109. actionManager: Nullable<AbstractActionManager>;
  36110. private _meshCollisionData;
  36111. /**
  36112. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36113. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36114. */
  36115. ellipsoid: Vector3;
  36116. /**
  36117. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36118. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36119. */
  36120. ellipsoidOffset: Vector3;
  36121. /**
  36122. * Gets or sets a collision mask used to mask collisions (default is -1).
  36123. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36124. */
  36125. get collisionMask(): number;
  36126. set collisionMask(mask: number);
  36127. /**
  36128. * Gets or sets a collision response flag (default is true).
  36129. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36130. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36131. * to respond to the collision.
  36132. */
  36133. get collisionResponse(): boolean;
  36134. set collisionResponse(response: boolean);
  36135. /**
  36136. * Gets or sets the current collision group mask (-1 by default).
  36137. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36138. */
  36139. get collisionGroup(): number;
  36140. set collisionGroup(mask: number);
  36141. /**
  36142. * Gets or sets current surrounding meshes (null by default).
  36143. *
  36144. * By default collision detection is tested against every mesh in the scene.
  36145. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36146. * meshes will be tested for the collision.
  36147. *
  36148. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36149. */
  36150. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36151. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36152. /**
  36153. * Defines edge width used when edgesRenderer is enabled
  36154. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36155. */
  36156. edgesWidth: number;
  36157. /**
  36158. * Defines edge color used when edgesRenderer is enabled
  36159. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36160. */
  36161. edgesColor: Color4;
  36162. /** @hidden */
  36163. _edgesRenderer: Nullable<IEdgesRenderer>;
  36164. /** @hidden */
  36165. _masterMesh: Nullable<AbstractMesh>;
  36166. /** @hidden */
  36167. _boundingInfo: Nullable<BoundingInfo>;
  36168. /** @hidden */
  36169. _renderId: number;
  36170. /**
  36171. * Gets or sets the list of subMeshes
  36172. * @see https://doc.babylonjs.com/how_to/multi_materials
  36173. */
  36174. subMeshes: SubMesh[];
  36175. /** @hidden */
  36176. _intersectionsInProgress: AbstractMesh[];
  36177. /** @hidden */
  36178. _unIndexed: boolean;
  36179. /** @hidden */
  36180. _lightSources: Light[];
  36181. /** Gets the list of lights affecting that mesh */
  36182. get lightSources(): Light[];
  36183. /** @hidden */
  36184. get _positions(): Nullable<Vector3[]>;
  36185. /** @hidden */
  36186. _waitingData: {
  36187. lods: Nullable<any>;
  36188. actions: Nullable<any>;
  36189. freezeWorldMatrix: Nullable<boolean>;
  36190. };
  36191. /** @hidden */
  36192. _bonesTransformMatrices: Nullable<Float32Array>;
  36193. /** @hidden */
  36194. _transformMatrixTexture: Nullable<RawTexture>;
  36195. /**
  36196. * Gets or sets a skeleton to apply skining transformations
  36197. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36198. */
  36199. set skeleton(value: Nullable<Skeleton>);
  36200. get skeleton(): Nullable<Skeleton>;
  36201. /**
  36202. * An event triggered when the mesh is rebuilt.
  36203. */
  36204. onRebuildObservable: Observable<AbstractMesh>;
  36205. /**
  36206. * The current mesh unifom buffer.
  36207. * @hidden Internal use only.
  36208. */
  36209. _uniformBuffer: UniformBuffer;
  36210. /**
  36211. * Creates a new AbstractMesh
  36212. * @param name defines the name of the mesh
  36213. * @param scene defines the hosting scene
  36214. */
  36215. constructor(name: string, scene?: Nullable<Scene>);
  36216. protected _buildUniformLayout(): void;
  36217. /**
  36218. * Transfer the mesh values to its UBO.
  36219. * @param world The world matrix associated with the mesh
  36220. */
  36221. transferToEffect(world: Matrix): void;
  36222. /**
  36223. * Gets the mesh uniform buffer.
  36224. * @return the uniform buffer of the mesh.
  36225. */
  36226. getMeshUniformBuffer(): UniformBuffer;
  36227. /**
  36228. * Returns the string "AbstractMesh"
  36229. * @returns "AbstractMesh"
  36230. */
  36231. getClassName(): string;
  36232. /**
  36233. * Gets a string representation of the current mesh
  36234. * @param fullDetails defines a boolean indicating if full details must be included
  36235. * @returns a string representation of the current mesh
  36236. */
  36237. toString(fullDetails?: boolean): string;
  36238. /**
  36239. * @hidden
  36240. */
  36241. protected _getEffectiveParent(): Nullable<Node>;
  36242. /** @hidden */
  36243. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36244. /** @hidden */
  36245. _rebuild(): void;
  36246. /** @hidden */
  36247. _resyncLightSources(): void;
  36248. /** @hidden */
  36249. _resyncLightSource(light: Light): void;
  36250. /** @hidden */
  36251. _unBindEffect(): void;
  36252. /** @hidden */
  36253. _removeLightSource(light: Light, dispose: boolean): void;
  36254. private _markSubMeshesAsDirty;
  36255. /** @hidden */
  36256. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36257. /** @hidden */
  36258. _markSubMeshesAsAttributesDirty(): void;
  36259. /** @hidden */
  36260. _markSubMeshesAsMiscDirty(): void;
  36261. /**
  36262. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36263. */
  36264. get scaling(): Vector3;
  36265. set scaling(newScaling: Vector3);
  36266. /**
  36267. * Returns true if the mesh is blocked. Implemented by child classes
  36268. */
  36269. get isBlocked(): boolean;
  36270. /**
  36271. * Returns the mesh itself by default. Implemented by child classes
  36272. * @param camera defines the camera to use to pick the right LOD level
  36273. * @returns the currentAbstractMesh
  36274. */
  36275. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36276. /**
  36277. * Returns 0 by default. Implemented by child classes
  36278. * @returns an integer
  36279. */
  36280. getTotalVertices(): number;
  36281. /**
  36282. * Returns a positive integer : the total number of indices in this mesh geometry.
  36283. * @returns the numner of indices or zero if the mesh has no geometry.
  36284. */
  36285. getTotalIndices(): number;
  36286. /**
  36287. * Returns null by default. Implemented by child classes
  36288. * @returns null
  36289. */
  36290. getIndices(): Nullable<IndicesArray>;
  36291. /**
  36292. * Returns the array of the requested vertex data kind. Implemented by child classes
  36293. * @param kind defines the vertex data kind to use
  36294. * @returns null
  36295. */
  36296. getVerticesData(kind: string): Nullable<FloatArray>;
  36297. /**
  36298. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36299. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36300. * Note that a new underlying VertexBuffer object is created each call.
  36301. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36302. * @param kind defines vertex data kind:
  36303. * * VertexBuffer.PositionKind
  36304. * * VertexBuffer.UVKind
  36305. * * VertexBuffer.UV2Kind
  36306. * * VertexBuffer.UV3Kind
  36307. * * VertexBuffer.UV4Kind
  36308. * * VertexBuffer.UV5Kind
  36309. * * VertexBuffer.UV6Kind
  36310. * * VertexBuffer.ColorKind
  36311. * * VertexBuffer.MatricesIndicesKind
  36312. * * VertexBuffer.MatricesIndicesExtraKind
  36313. * * VertexBuffer.MatricesWeightsKind
  36314. * * VertexBuffer.MatricesWeightsExtraKind
  36315. * @param data defines the data source
  36316. * @param updatable defines if the data must be flagged as updatable (or static)
  36317. * @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
  36318. * @returns the current mesh
  36319. */
  36320. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36321. /**
  36322. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36323. * If the mesh has no geometry, it is simply returned as it is.
  36324. * @param kind defines vertex data kind:
  36325. * * VertexBuffer.PositionKind
  36326. * * VertexBuffer.UVKind
  36327. * * VertexBuffer.UV2Kind
  36328. * * VertexBuffer.UV3Kind
  36329. * * VertexBuffer.UV4Kind
  36330. * * VertexBuffer.UV5Kind
  36331. * * VertexBuffer.UV6Kind
  36332. * * VertexBuffer.ColorKind
  36333. * * VertexBuffer.MatricesIndicesKind
  36334. * * VertexBuffer.MatricesIndicesExtraKind
  36335. * * VertexBuffer.MatricesWeightsKind
  36336. * * VertexBuffer.MatricesWeightsExtraKind
  36337. * @param data defines the data source
  36338. * @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
  36339. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36340. * @returns the current mesh
  36341. */
  36342. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36343. /**
  36344. * Sets the mesh indices,
  36345. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36346. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36347. * @param totalVertices Defines the total number of vertices
  36348. * @returns the current mesh
  36349. */
  36350. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36351. /**
  36352. * Gets a boolean indicating if specific vertex data is present
  36353. * @param kind defines the vertex data kind to use
  36354. * @returns true is data kind is present
  36355. */
  36356. isVerticesDataPresent(kind: string): boolean;
  36357. /**
  36358. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36359. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36360. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36361. * @returns a BoundingInfo
  36362. */
  36363. getBoundingInfo(): BoundingInfo;
  36364. /**
  36365. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36366. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36367. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36368. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36369. * @returns the current mesh
  36370. */
  36371. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36372. /**
  36373. * Overwrite the current bounding info
  36374. * @param boundingInfo defines the new bounding info
  36375. * @returns the current mesh
  36376. */
  36377. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36378. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36379. get useBones(): boolean;
  36380. /** @hidden */
  36381. _preActivate(): void;
  36382. /** @hidden */
  36383. _preActivateForIntermediateRendering(renderId: number): void;
  36384. /** @hidden */
  36385. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36386. /** @hidden */
  36387. _postActivate(): void;
  36388. /** @hidden */
  36389. _freeze(): void;
  36390. /** @hidden */
  36391. _unFreeze(): void;
  36392. /**
  36393. * Gets the current world matrix
  36394. * @returns a Matrix
  36395. */
  36396. getWorldMatrix(): Matrix;
  36397. /** @hidden */
  36398. _getWorldMatrixDeterminant(): number;
  36399. /**
  36400. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36401. */
  36402. get isAnInstance(): boolean;
  36403. /**
  36404. * Gets a boolean indicating if this mesh has instances
  36405. */
  36406. get hasInstances(): boolean;
  36407. /**
  36408. * Gets a boolean indicating if this mesh has thin instances
  36409. */
  36410. get hasThinInstances(): boolean;
  36411. /**
  36412. * Perform relative position change from the point of view of behind the front of the mesh.
  36413. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36414. * Supports definition of mesh facing forward or backward
  36415. * @param amountRight defines the distance on the right axis
  36416. * @param amountUp defines the distance on the up axis
  36417. * @param amountForward defines the distance on the forward axis
  36418. * @returns the current mesh
  36419. */
  36420. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36421. /**
  36422. * Calculate relative position change from the point of view of behind the front of the mesh.
  36423. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36424. * Supports definition of mesh facing forward or backward
  36425. * @param amountRight defines the distance on the right axis
  36426. * @param amountUp defines the distance on the up axis
  36427. * @param amountForward defines the distance on the forward axis
  36428. * @returns the new displacement vector
  36429. */
  36430. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36431. /**
  36432. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36433. * Supports definition of mesh facing forward or backward
  36434. * @param flipBack defines the flip
  36435. * @param twirlClockwise defines the twirl
  36436. * @param tiltRight defines the tilt
  36437. * @returns the current mesh
  36438. */
  36439. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36440. /**
  36441. * Calculate 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 new rotation vector
  36447. */
  36448. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36449. /**
  36450. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36451. * This means the mesh underlying bounding box and sphere are recomputed.
  36452. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36453. * @returns the current mesh
  36454. */
  36455. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36456. /** @hidden */
  36457. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36458. /** @hidden */
  36459. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36460. /** @hidden */
  36461. _updateBoundingInfo(): AbstractMesh;
  36462. /** @hidden */
  36463. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36464. /** @hidden */
  36465. protected _afterComputeWorldMatrix(): void;
  36466. /** @hidden */
  36467. get _effectiveMesh(): AbstractMesh;
  36468. /**
  36469. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36470. * A mesh is in the frustum if its bounding box intersects the frustum
  36471. * @param frustumPlanes defines the frustum to test
  36472. * @returns true if the mesh is in the frustum planes
  36473. */
  36474. isInFrustum(frustumPlanes: Plane[]): boolean;
  36475. /**
  36476. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36477. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36478. * @param frustumPlanes defines the frustum to test
  36479. * @returns true if the mesh is completely in the frustum planes
  36480. */
  36481. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36482. /**
  36483. * True if the mesh intersects another mesh or a SolidParticle object
  36484. * @param mesh defines a target mesh or SolidParticle to test
  36485. * @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)
  36486. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36487. * @returns true if there is an intersection
  36488. */
  36489. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36490. /**
  36491. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36492. * @param point defines the point to test
  36493. * @returns true if there is an intersection
  36494. */
  36495. intersectsPoint(point: Vector3): boolean;
  36496. /**
  36497. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36498. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36499. */
  36500. get checkCollisions(): boolean;
  36501. set checkCollisions(collisionEnabled: boolean);
  36502. /**
  36503. * Gets Collider object used to compute collisions (not physics)
  36504. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36505. */
  36506. get collider(): Nullable<Collider>;
  36507. /**
  36508. * Move the mesh using collision engine
  36509. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36510. * @param displacement defines the requested displacement vector
  36511. * @returns the current mesh
  36512. */
  36513. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36514. private _onCollisionPositionChange;
  36515. /** @hidden */
  36516. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36517. /** @hidden */
  36518. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36519. /** @hidden */
  36520. _checkCollision(collider: Collider): AbstractMesh;
  36521. /** @hidden */
  36522. _generatePointsArray(): boolean;
  36523. /**
  36524. * Checks if the passed Ray intersects with the mesh
  36525. * @param ray defines the ray to use
  36526. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36527. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36528. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36529. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36530. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36531. * @returns the picking info
  36532. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36533. */
  36534. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36535. /**
  36536. * Clones the current mesh
  36537. * @param name defines the mesh name
  36538. * @param newParent defines the new mesh parent
  36539. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36540. * @returns the new mesh
  36541. */
  36542. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36543. /**
  36544. * Disposes all the submeshes of the current meshnp
  36545. * @returns the current mesh
  36546. */
  36547. releaseSubMeshes(): AbstractMesh;
  36548. /**
  36549. * Releases resources associated with this abstract mesh.
  36550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36552. */
  36553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36554. /**
  36555. * Adds the passed mesh as a child to the current mesh
  36556. * @param mesh defines the child mesh
  36557. * @returns the current mesh
  36558. */
  36559. addChild(mesh: AbstractMesh): AbstractMesh;
  36560. /**
  36561. * Removes the passed mesh from the current mesh children list
  36562. * @param mesh defines the child mesh
  36563. * @returns the current mesh
  36564. */
  36565. removeChild(mesh: AbstractMesh): AbstractMesh;
  36566. /** @hidden */
  36567. private _initFacetData;
  36568. /**
  36569. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36570. * This method can be called within the render loop.
  36571. * 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
  36572. * @returns the current mesh
  36573. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36574. */
  36575. updateFacetData(): AbstractMesh;
  36576. /**
  36577. * Returns the facetLocalNormals array.
  36578. * The normals are expressed in the mesh local spac
  36579. * @returns an array of Vector3
  36580. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36581. */
  36582. getFacetLocalNormals(): Vector3[];
  36583. /**
  36584. * Returns the facetLocalPositions array.
  36585. * The facet positions are expressed in the mesh local space
  36586. * @returns an array of Vector3
  36587. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36588. */
  36589. getFacetLocalPositions(): Vector3[];
  36590. /**
  36591. * Returns the facetLocalPartioning array
  36592. * @returns an array of array of numbers
  36593. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36594. */
  36595. getFacetLocalPartitioning(): number[][];
  36596. /**
  36597. * Returns the i-th facet position in the world system.
  36598. * This method allocates a new Vector3 per call
  36599. * @param i defines the facet index
  36600. * @returns a new Vector3
  36601. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36602. */
  36603. getFacetPosition(i: number): Vector3;
  36604. /**
  36605. * Sets the reference Vector3 with the i-th facet position in the world system
  36606. * @param i defines the facet index
  36607. * @param ref defines the target vector
  36608. * @returns the current mesh
  36609. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36610. */
  36611. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36612. /**
  36613. * Returns the i-th facet normal in the world system.
  36614. * This method allocates a new Vector3 per call
  36615. * @param i defines the facet index
  36616. * @returns a new Vector3
  36617. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36618. */
  36619. getFacetNormal(i: number): Vector3;
  36620. /**
  36621. * Sets the reference Vector3 with the i-th facet normal in the world system
  36622. * @param i defines the facet index
  36623. * @param ref defines the target vector
  36624. * @returns the current mesh
  36625. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36626. */
  36627. getFacetNormalToRef(i: number, ref: Vector3): this;
  36628. /**
  36629. * 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)
  36630. * @param x defines x coordinate
  36631. * @param y defines y coordinate
  36632. * @param z defines z coordinate
  36633. * @returns the array of facet indexes
  36634. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36635. */
  36636. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36637. /**
  36638. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36639. * @param projected sets as the (x,y,z) world projection on the facet
  36640. * @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
  36641. * @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
  36642. * @param x defines x coordinate
  36643. * @param y defines y coordinate
  36644. * @param z defines z coordinate
  36645. * @returns the face index if found (or null instead)
  36646. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36647. */
  36648. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36649. /**
  36650. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36651. * @param projected sets as the (x,y,z) local projection on the facet
  36652. * @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
  36653. * @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
  36654. * @param x defines x coordinate
  36655. * @param y defines y coordinate
  36656. * @param z defines z coordinate
  36657. * @returns the face index if found (or null instead)
  36658. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36659. */
  36660. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36661. /**
  36662. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36663. * @returns the parameters
  36664. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36665. */
  36666. getFacetDataParameters(): any;
  36667. /**
  36668. * Disables the feature FacetData and frees the related memory
  36669. * @returns the current mesh
  36670. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36671. */
  36672. disableFacetData(): AbstractMesh;
  36673. /**
  36674. * Updates the AbstractMesh indices array
  36675. * @param indices defines the data source
  36676. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36677. * @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)
  36678. * @returns the current mesh
  36679. */
  36680. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36681. /**
  36682. * Creates new normals data for the mesh
  36683. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36684. * @returns the current mesh
  36685. */
  36686. createNormals(updatable: boolean): AbstractMesh;
  36687. /**
  36688. * Align the mesh with a normal
  36689. * @param normal defines the normal to use
  36690. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36691. * @returns the current mesh
  36692. */
  36693. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36694. /** @hidden */
  36695. _checkOcclusionQuery(): boolean;
  36696. /**
  36697. * Disables the mesh edge rendering mode
  36698. * @returns the currentAbstractMesh
  36699. */
  36700. disableEdgesRendering(): AbstractMesh;
  36701. /**
  36702. * Enables the edge rendering mode on the mesh.
  36703. * This mode makes the mesh edges visible
  36704. * @param epsilon defines the maximal distance between two angles to detect a face
  36705. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36706. * @param options options to the edge renderer
  36707. * @returns the currentAbstractMesh
  36708. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36709. */
  36710. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  36711. /**
  36712. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36713. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36714. */
  36715. getConnectedParticleSystems(): IParticleSystem[];
  36716. }
  36717. }
  36718. declare module BABYLON {
  36719. /**
  36720. * Interface used to define ActionEvent
  36721. */
  36722. export interface IActionEvent {
  36723. /** The mesh or sprite that triggered the action */
  36724. source: any;
  36725. /** The X mouse cursor position at the time of the event */
  36726. pointerX: number;
  36727. /** The Y mouse cursor position at the time of the event */
  36728. pointerY: number;
  36729. /** The mesh that is currently pointed at (can be null) */
  36730. meshUnderPointer: Nullable<AbstractMesh>;
  36731. /** the original (browser) event that triggered the ActionEvent */
  36732. sourceEvent?: any;
  36733. /** additional data for the event */
  36734. additionalData?: any;
  36735. }
  36736. /**
  36737. * ActionEvent is the event being sent when an action is triggered.
  36738. */
  36739. export class ActionEvent implements IActionEvent {
  36740. /** The mesh or sprite that triggered the action */
  36741. source: any;
  36742. /** The X mouse cursor position at the time of the event */
  36743. pointerX: number;
  36744. /** The Y mouse cursor position at the time of the event */
  36745. pointerY: number;
  36746. /** The mesh that is currently pointed at (can be null) */
  36747. meshUnderPointer: Nullable<AbstractMesh>;
  36748. /** the original (browser) event that triggered the ActionEvent */
  36749. sourceEvent?: any;
  36750. /** additional data for the event */
  36751. additionalData?: any;
  36752. /**
  36753. * Creates a new ActionEvent
  36754. * @param source The mesh or sprite that triggered the action
  36755. * @param pointerX The X mouse cursor position at the time of the event
  36756. * @param pointerY The Y mouse cursor position at the time of the event
  36757. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36758. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36759. * @param additionalData additional data for the event
  36760. */
  36761. constructor(
  36762. /** The mesh or sprite that triggered the action */
  36763. source: any,
  36764. /** The X mouse cursor position at the time of the event */
  36765. pointerX: number,
  36766. /** The Y mouse cursor position at the time of the event */
  36767. pointerY: number,
  36768. /** The mesh that is currently pointed at (can be null) */
  36769. meshUnderPointer: Nullable<AbstractMesh>,
  36770. /** the original (browser) event that triggered the ActionEvent */
  36771. sourceEvent?: any,
  36772. /** additional data for the event */
  36773. additionalData?: any);
  36774. /**
  36775. * Helper function to auto-create an ActionEvent from a source mesh.
  36776. * @param source The source mesh that triggered the event
  36777. * @param evt The original (browser) event
  36778. * @param additionalData additional data for the event
  36779. * @returns the new ActionEvent
  36780. */
  36781. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36782. /**
  36783. * Helper function to auto-create an ActionEvent from a source sprite
  36784. * @param source The source sprite that triggered the event
  36785. * @param scene Scene associated with the sprite
  36786. * @param evt The original (browser) event
  36787. * @param additionalData additional data for the event
  36788. * @returns the new ActionEvent
  36789. */
  36790. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36791. /**
  36792. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36793. * @param scene the scene where the event occurred
  36794. * @param evt The original (browser) event
  36795. * @returns the new ActionEvent
  36796. */
  36797. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36798. /**
  36799. * Helper function to auto-create an ActionEvent from a primitive
  36800. * @param prim defines the target primitive
  36801. * @param pointerPos defines the pointer position
  36802. * @param evt The original (browser) event
  36803. * @param additionalData additional data for the event
  36804. * @returns the new ActionEvent
  36805. */
  36806. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36807. }
  36808. }
  36809. declare module BABYLON {
  36810. /**
  36811. * Abstract class used to decouple action Manager from scene and meshes.
  36812. * Do not instantiate.
  36813. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36814. */
  36815. export abstract class AbstractActionManager implements IDisposable {
  36816. /** Gets the list of active triggers */
  36817. static Triggers: {
  36818. [key: string]: number;
  36819. };
  36820. /** Gets the cursor to use when hovering items */
  36821. hoverCursor: string;
  36822. /** Gets the list of actions */
  36823. actions: IAction[];
  36824. /**
  36825. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36826. */
  36827. isRecursive: boolean;
  36828. /**
  36829. * Releases all associated resources
  36830. */
  36831. abstract dispose(): void;
  36832. /**
  36833. * Does this action manager has pointer triggers
  36834. */
  36835. abstract get hasPointerTriggers(): boolean;
  36836. /**
  36837. * Does this action manager has pick triggers
  36838. */
  36839. abstract get hasPickTriggers(): boolean;
  36840. /**
  36841. * Process a specific trigger
  36842. * @param trigger defines the trigger to process
  36843. * @param evt defines the event details to be processed
  36844. */
  36845. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36846. /**
  36847. * Does this action manager handles actions of any of the given triggers
  36848. * @param triggers defines the triggers to be tested
  36849. * @return a boolean indicating whether one (or more) of the triggers is handled
  36850. */
  36851. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36852. /**
  36853. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36854. * speed.
  36855. * @param triggerA defines the trigger to be tested
  36856. * @param triggerB defines the trigger to be tested
  36857. * @return a boolean indicating whether one (or more) of the triggers is handled
  36858. */
  36859. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36860. /**
  36861. * Does this action manager handles actions of a given trigger
  36862. * @param trigger defines the trigger to be tested
  36863. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36864. * @return whether the trigger is handled
  36865. */
  36866. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36867. /**
  36868. * Serialize this manager to a JSON object
  36869. * @param name defines the property name to store this manager
  36870. * @returns a JSON representation of this manager
  36871. */
  36872. abstract serialize(name: string): any;
  36873. /**
  36874. * Registers an action to this action manager
  36875. * @param action defines the action to be registered
  36876. * @return the action amended (prepared) after registration
  36877. */
  36878. abstract registerAction(action: IAction): Nullable<IAction>;
  36879. /**
  36880. * Unregisters an action to this action manager
  36881. * @param action defines the action to be unregistered
  36882. * @return a boolean indicating whether the action has been unregistered
  36883. */
  36884. abstract unregisterAction(action: IAction): Boolean;
  36885. /**
  36886. * Does exist one action manager with at least one trigger
  36887. **/
  36888. static get HasTriggers(): boolean;
  36889. /**
  36890. * Does exist one action manager with at least one pick trigger
  36891. **/
  36892. static get HasPickTriggers(): boolean;
  36893. /**
  36894. * Does exist one action manager that handles actions of a given trigger
  36895. * @param trigger defines the trigger to be tested
  36896. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36897. **/
  36898. static HasSpecificTrigger(trigger: number): boolean;
  36899. }
  36900. }
  36901. declare module BABYLON {
  36902. /**
  36903. * Defines how a node can be built from a string name.
  36904. */
  36905. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36906. /**
  36907. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36908. */
  36909. export class Node implements IBehaviorAware<Node> {
  36910. /** @hidden */
  36911. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36912. private static _NodeConstructors;
  36913. /**
  36914. * Add a new node constructor
  36915. * @param type defines the type name of the node to construct
  36916. * @param constructorFunc defines the constructor function
  36917. */
  36918. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36919. /**
  36920. * Returns a node constructor based on type name
  36921. * @param type defines the type name
  36922. * @param name defines the new node name
  36923. * @param scene defines the hosting scene
  36924. * @param options defines optional options to transmit to constructors
  36925. * @returns the new constructor or null
  36926. */
  36927. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36928. /**
  36929. * Gets or sets the name of the node
  36930. */
  36931. name: string;
  36932. /**
  36933. * Gets or sets the id of the node
  36934. */
  36935. id: string;
  36936. /**
  36937. * Gets or sets the unique id of the node
  36938. */
  36939. uniqueId: number;
  36940. /**
  36941. * Gets or sets a string used to store user defined state for the node
  36942. */
  36943. state: string;
  36944. /**
  36945. * Gets or sets an object used to store user defined information for the node
  36946. */
  36947. metadata: any;
  36948. /**
  36949. * For internal use only. Please do not use.
  36950. */
  36951. reservedDataStore: any;
  36952. /**
  36953. * List of inspectable custom properties (used by the Inspector)
  36954. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36955. */
  36956. inspectableCustomProperties: IInspectable[];
  36957. private _doNotSerialize;
  36958. /**
  36959. * Gets or sets a boolean used to define if the node must be serialized
  36960. */
  36961. get doNotSerialize(): boolean;
  36962. set doNotSerialize(value: boolean);
  36963. /** @hidden */
  36964. _isDisposed: boolean;
  36965. /**
  36966. * Gets a list of Animations associated with the node
  36967. */
  36968. animations: Animation[];
  36969. protected _ranges: {
  36970. [name: string]: Nullable<AnimationRange>;
  36971. };
  36972. /**
  36973. * Callback raised when the node is ready to be used
  36974. */
  36975. onReady: Nullable<(node: Node) => void>;
  36976. private _isEnabled;
  36977. private _isParentEnabled;
  36978. private _isReady;
  36979. /** @hidden */
  36980. _currentRenderId: number;
  36981. private _parentUpdateId;
  36982. /** @hidden */
  36983. _childUpdateId: number;
  36984. /** @hidden */
  36985. _waitingParentId: Nullable<string>;
  36986. /** @hidden */
  36987. _scene: Scene;
  36988. /** @hidden */
  36989. _cache: any;
  36990. private _parentNode;
  36991. private _children;
  36992. /** @hidden */
  36993. _worldMatrix: Matrix;
  36994. /** @hidden */
  36995. _worldMatrixDeterminant: number;
  36996. /** @hidden */
  36997. _worldMatrixDeterminantIsDirty: boolean;
  36998. /** @hidden */
  36999. private _sceneRootNodesIndex;
  37000. /**
  37001. * Gets a boolean indicating if the node has been disposed
  37002. * @returns true if the node was disposed
  37003. */
  37004. isDisposed(): boolean;
  37005. /**
  37006. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37007. * @see https://doc.babylonjs.com/how_to/parenting
  37008. */
  37009. set parent(parent: Nullable<Node>);
  37010. get parent(): Nullable<Node>;
  37011. /** @hidden */
  37012. _addToSceneRootNodes(): void;
  37013. /** @hidden */
  37014. _removeFromSceneRootNodes(): void;
  37015. private _animationPropertiesOverride;
  37016. /**
  37017. * Gets or sets the animation properties override
  37018. */
  37019. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37020. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37021. /**
  37022. * Gets a string identifying the name of the class
  37023. * @returns "Node" string
  37024. */
  37025. getClassName(): string;
  37026. /** @hidden */
  37027. readonly _isNode: boolean;
  37028. /**
  37029. * An event triggered when the mesh is disposed
  37030. */
  37031. onDisposeObservable: Observable<Node>;
  37032. private _onDisposeObserver;
  37033. /**
  37034. * Sets a callback that will be raised when the node will be disposed
  37035. */
  37036. set onDispose(callback: () => void);
  37037. /**
  37038. * Creates a new Node
  37039. * @param name the name and id to be given to this node
  37040. * @param scene the scene this node will be added to
  37041. */
  37042. constructor(name: string, scene?: Nullable<Scene>);
  37043. /**
  37044. * Gets the scene of the node
  37045. * @returns a scene
  37046. */
  37047. getScene(): Scene;
  37048. /**
  37049. * Gets the engine of the node
  37050. * @returns a Engine
  37051. */
  37052. getEngine(): Engine;
  37053. private _behaviors;
  37054. /**
  37055. * Attach a behavior to the node
  37056. * @see https://doc.babylonjs.com/features/behaviour
  37057. * @param behavior defines the behavior to attach
  37058. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37059. * @returns the current Node
  37060. */
  37061. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37062. /**
  37063. * Remove an attached behavior
  37064. * @see https://doc.babylonjs.com/features/behaviour
  37065. * @param behavior defines the behavior to attach
  37066. * @returns the current Node
  37067. */
  37068. removeBehavior(behavior: Behavior<Node>): Node;
  37069. /**
  37070. * Gets the list of attached behaviors
  37071. * @see https://doc.babylonjs.com/features/behaviour
  37072. */
  37073. get behaviors(): Behavior<Node>[];
  37074. /**
  37075. * Gets an attached behavior by name
  37076. * @param name defines the name of the behavior to look for
  37077. * @see https://doc.babylonjs.com/features/behaviour
  37078. * @returns null if behavior was not found else the requested behavior
  37079. */
  37080. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37081. /**
  37082. * Returns the latest update of the World matrix
  37083. * @returns a Matrix
  37084. */
  37085. getWorldMatrix(): Matrix;
  37086. /** @hidden */
  37087. _getWorldMatrixDeterminant(): number;
  37088. /**
  37089. * Returns directly the latest state of the mesh World matrix.
  37090. * A Matrix is returned.
  37091. */
  37092. get worldMatrixFromCache(): Matrix;
  37093. /** @hidden */
  37094. _initCache(): void;
  37095. /** @hidden */
  37096. updateCache(force?: boolean): void;
  37097. /** @hidden */
  37098. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37099. /** @hidden */
  37100. _updateCache(ignoreParentClass?: boolean): void;
  37101. /** @hidden */
  37102. _isSynchronized(): boolean;
  37103. /** @hidden */
  37104. _markSyncedWithParent(): void;
  37105. /** @hidden */
  37106. isSynchronizedWithParent(): boolean;
  37107. /** @hidden */
  37108. isSynchronized(): boolean;
  37109. /**
  37110. * Is this node ready to be used/rendered
  37111. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37112. * @return true if the node is ready
  37113. */
  37114. isReady(completeCheck?: boolean): boolean;
  37115. /**
  37116. * Is this node enabled?
  37117. * 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
  37118. * @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
  37119. * @return whether this node (and its parent) is enabled
  37120. */
  37121. isEnabled(checkAncestors?: boolean): boolean;
  37122. /** @hidden */
  37123. protected _syncParentEnabledState(): void;
  37124. /**
  37125. * Set the enabled state of this node
  37126. * @param value defines the new enabled state
  37127. */
  37128. setEnabled(value: boolean): void;
  37129. /**
  37130. * Is this node a descendant of the given node?
  37131. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37132. * @param ancestor defines the parent node to inspect
  37133. * @returns a boolean indicating if this node is a descendant of the given node
  37134. */
  37135. isDescendantOf(ancestor: Node): boolean;
  37136. /** @hidden */
  37137. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37138. /**
  37139. * Will return all nodes that have this node as ascendant
  37140. * @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
  37141. * @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
  37142. * @return all children nodes of all types
  37143. */
  37144. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37145. /**
  37146. * Get all child-meshes of this node
  37147. * @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)
  37148. * @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
  37149. * @returns an array of AbstractMesh
  37150. */
  37151. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37152. /**
  37153. * Get all direct children of this node
  37154. * @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
  37155. * @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)
  37156. * @returns an array of Node
  37157. */
  37158. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37159. /** @hidden */
  37160. _setReady(state: boolean): void;
  37161. /**
  37162. * Get an animation by name
  37163. * @param name defines the name of the animation to look for
  37164. * @returns null if not found else the requested animation
  37165. */
  37166. getAnimationByName(name: string): Nullable<Animation>;
  37167. /**
  37168. * Creates an animation range for this node
  37169. * @param name defines the name of the range
  37170. * @param from defines the starting key
  37171. * @param to defines the end key
  37172. */
  37173. createAnimationRange(name: string, from: number, to: number): void;
  37174. /**
  37175. * Delete a specific animation range
  37176. * @param name defines the name of the range to delete
  37177. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37178. */
  37179. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37180. /**
  37181. * Get an animation range by name
  37182. * @param name defines the name of the animation range to look for
  37183. * @returns null if not found else the requested animation range
  37184. */
  37185. getAnimationRange(name: string): Nullable<AnimationRange>;
  37186. /**
  37187. * Gets the list of all animation ranges defined on this node
  37188. * @returns an array
  37189. */
  37190. getAnimationRanges(): Nullable<AnimationRange>[];
  37191. /**
  37192. * Will start the animation sequence
  37193. * @param name defines the range frames for animation sequence
  37194. * @param loop defines if the animation should loop (false by default)
  37195. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37196. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37197. * @returns the object created for this animation. If range does not exist, it will return null
  37198. */
  37199. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37200. /**
  37201. * Serialize animation ranges into a JSON compatible object
  37202. * @returns serialization object
  37203. */
  37204. serializeAnimationRanges(): any;
  37205. /**
  37206. * Computes the world matrix of the node
  37207. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37208. * @returns the world matrix
  37209. */
  37210. computeWorldMatrix(force?: boolean): Matrix;
  37211. /**
  37212. * Releases resources associated with this node.
  37213. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37214. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37215. */
  37216. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37217. /**
  37218. * Parse animation range data from a serialization object and store them into a given node
  37219. * @param node defines where to store the animation ranges
  37220. * @param parsedNode defines the serialization object to read data from
  37221. * @param scene defines the hosting scene
  37222. */
  37223. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37224. /**
  37225. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37226. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37227. * @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
  37228. * @returns the new bounding vectors
  37229. */
  37230. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37231. min: Vector3;
  37232. max: Vector3;
  37233. };
  37234. }
  37235. }
  37236. declare module BABYLON {
  37237. /**
  37238. * @hidden
  37239. */
  37240. export class _IAnimationState {
  37241. key: number;
  37242. repeatCount: number;
  37243. workValue?: any;
  37244. loopMode?: number;
  37245. offsetValue?: any;
  37246. highLimitValue?: any;
  37247. }
  37248. /**
  37249. * Class used to store any kind of animation
  37250. */
  37251. export class Animation {
  37252. /**Name of the animation */
  37253. name: string;
  37254. /**Property to animate */
  37255. targetProperty: string;
  37256. /**The frames per second of the animation */
  37257. framePerSecond: number;
  37258. /**The data type of the animation */
  37259. dataType: number;
  37260. /**The loop mode of the animation */
  37261. loopMode?: number | undefined;
  37262. /**Specifies if blending should be enabled */
  37263. enableBlending?: boolean | undefined;
  37264. /**
  37265. * Use matrix interpolation instead of using direct key value when animating matrices
  37266. */
  37267. static AllowMatricesInterpolation: boolean;
  37268. /**
  37269. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37270. */
  37271. static AllowMatrixDecomposeForInterpolation: boolean;
  37272. /** Define the Url to load snippets */
  37273. static SnippetUrl: string;
  37274. /** Snippet ID if the animation was created from the snippet server */
  37275. snippetId: string;
  37276. /**
  37277. * Stores the key frames of the animation
  37278. */
  37279. private _keys;
  37280. /**
  37281. * Stores the easing function of the animation
  37282. */
  37283. private _easingFunction;
  37284. /**
  37285. * @hidden Internal use only
  37286. */
  37287. _runtimeAnimations: RuntimeAnimation[];
  37288. /**
  37289. * The set of event that will be linked to this animation
  37290. */
  37291. private _events;
  37292. /**
  37293. * Stores an array of target property paths
  37294. */
  37295. targetPropertyPath: string[];
  37296. /**
  37297. * Stores the blending speed of the animation
  37298. */
  37299. blendingSpeed: number;
  37300. /**
  37301. * Stores the animation ranges for the animation
  37302. */
  37303. private _ranges;
  37304. /**
  37305. * @hidden Internal use
  37306. */
  37307. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37308. /**
  37309. * Sets up an animation
  37310. * @param property The property to animate
  37311. * @param animationType The animation type to apply
  37312. * @param framePerSecond The frames per second of the animation
  37313. * @param easingFunction The easing function used in the animation
  37314. * @returns The created animation
  37315. */
  37316. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37317. /**
  37318. * Create and start an animation on a node
  37319. * @param name defines the name of the global animation that will be run on all nodes
  37320. * @param node defines the root node where the animation will take place
  37321. * @param targetProperty defines property to animate
  37322. * @param framePerSecond defines the number of frame per second yo use
  37323. * @param totalFrame defines the number of frames in total
  37324. * @param from defines the initial value
  37325. * @param to defines the final value
  37326. * @param loopMode defines which loop mode you want to use (off by default)
  37327. * @param easingFunction defines the easing function to use (linear by default)
  37328. * @param onAnimationEnd defines the callback to call when animation end
  37329. * @returns the animatable created for this animation
  37330. */
  37331. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37332. /**
  37333. * Create and start an animation on a node and its descendants
  37334. * @param name defines the name of the global animation that will be run on all nodes
  37335. * @param node defines the root node where the animation will take place
  37336. * @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
  37337. * @param targetProperty defines property to animate
  37338. * @param framePerSecond defines the number of frame per second to use
  37339. * @param totalFrame defines the number of frames in total
  37340. * @param from defines the initial value
  37341. * @param to defines the final value
  37342. * @param loopMode defines which loop mode you want to use (off by default)
  37343. * @param easingFunction defines the easing function to use (linear by default)
  37344. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37345. * @returns the list of animatables created for all nodes
  37346. * @example https://www.babylonjs-playground.com/#MH0VLI
  37347. */
  37348. 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[]>;
  37349. /**
  37350. * Creates a new animation, merges it with the existing animations and starts it
  37351. * @param name Name of the animation
  37352. * @param node Node which contains the scene that begins the animations
  37353. * @param targetProperty Specifies which property to animate
  37354. * @param framePerSecond The frames per second of the animation
  37355. * @param totalFrame The total number of frames
  37356. * @param from The frame at the beginning of the animation
  37357. * @param to The frame at the end of the animation
  37358. * @param loopMode Specifies the loop mode of the animation
  37359. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37360. * @param onAnimationEnd Callback to run once the animation is complete
  37361. * @returns Nullable animation
  37362. */
  37363. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37364. /**
  37365. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37366. * @param sourceAnimation defines the Animation containing keyframes to convert
  37367. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37368. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37369. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37370. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37371. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37372. */
  37373. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37374. /**
  37375. * Transition property of an host to the target Value
  37376. * @param property The property to transition
  37377. * @param targetValue The target Value of the property
  37378. * @param host The object where the property to animate belongs
  37379. * @param scene Scene used to run the animation
  37380. * @param frameRate Framerate (in frame/s) to use
  37381. * @param transition The transition type we want to use
  37382. * @param duration The duration of the animation, in milliseconds
  37383. * @param onAnimationEnd Callback trigger at the end of the animation
  37384. * @returns Nullable animation
  37385. */
  37386. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37387. /**
  37388. * Return the array of runtime animations currently using this animation
  37389. */
  37390. get runtimeAnimations(): RuntimeAnimation[];
  37391. /**
  37392. * Specifies if any of the runtime animations are currently running
  37393. */
  37394. get hasRunningRuntimeAnimations(): boolean;
  37395. /**
  37396. * Initializes the animation
  37397. * @param name Name of the animation
  37398. * @param targetProperty Property to animate
  37399. * @param framePerSecond The frames per second of the animation
  37400. * @param dataType The data type of the animation
  37401. * @param loopMode The loop mode of the animation
  37402. * @param enableBlending Specifies if blending should be enabled
  37403. */
  37404. constructor(
  37405. /**Name of the animation */
  37406. name: string,
  37407. /**Property to animate */
  37408. targetProperty: string,
  37409. /**The frames per second of the animation */
  37410. framePerSecond: number,
  37411. /**The data type of the animation */
  37412. dataType: number,
  37413. /**The loop mode of the animation */
  37414. loopMode?: number | undefined,
  37415. /**Specifies if blending should be enabled */
  37416. enableBlending?: boolean | undefined);
  37417. /**
  37418. * Converts the animation to a string
  37419. * @param fullDetails support for multiple levels of logging within scene loading
  37420. * @returns String form of the animation
  37421. */
  37422. toString(fullDetails?: boolean): string;
  37423. /**
  37424. * Add an event to this animation
  37425. * @param event Event to add
  37426. */
  37427. addEvent(event: AnimationEvent): void;
  37428. /**
  37429. * Remove all events found at the given frame
  37430. * @param frame The frame to remove events from
  37431. */
  37432. removeEvents(frame: number): void;
  37433. /**
  37434. * Retrieves all the events from the animation
  37435. * @returns Events from the animation
  37436. */
  37437. getEvents(): AnimationEvent[];
  37438. /**
  37439. * Creates an animation range
  37440. * @param name Name of the animation range
  37441. * @param from Starting frame of the animation range
  37442. * @param to Ending frame of the animation
  37443. */
  37444. createRange(name: string, from: number, to: number): void;
  37445. /**
  37446. * Deletes an animation range by name
  37447. * @param name Name of the animation range to delete
  37448. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37449. */
  37450. deleteRange(name: string, deleteFrames?: boolean): void;
  37451. /**
  37452. * Gets the animation range by name, or null if not defined
  37453. * @param name Name of the animation range
  37454. * @returns Nullable animation range
  37455. */
  37456. getRange(name: string): Nullable<AnimationRange>;
  37457. /**
  37458. * Gets the key frames from the animation
  37459. * @returns The key frames of the animation
  37460. */
  37461. getKeys(): Array<IAnimationKey>;
  37462. /**
  37463. * Gets the highest frame rate of the animation
  37464. * @returns Highest frame rate of the animation
  37465. */
  37466. getHighestFrame(): number;
  37467. /**
  37468. * Gets the easing function of the animation
  37469. * @returns Easing function of the animation
  37470. */
  37471. getEasingFunction(): IEasingFunction;
  37472. /**
  37473. * Sets the easing function of the animation
  37474. * @param easingFunction A custom mathematical formula for animation
  37475. */
  37476. setEasingFunction(easingFunction: EasingFunction): void;
  37477. /**
  37478. * Interpolates a scalar linearly
  37479. * @param startValue Start value of the animation curve
  37480. * @param endValue End value of the animation curve
  37481. * @param gradient Scalar amount to interpolate
  37482. * @returns Interpolated scalar value
  37483. */
  37484. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37485. /**
  37486. * Interpolates a scalar cubically
  37487. * @param startValue Start value of the animation curve
  37488. * @param outTangent End tangent of the animation
  37489. * @param endValue End value of the animation curve
  37490. * @param inTangent Start tangent of the animation curve
  37491. * @param gradient Scalar amount to interpolate
  37492. * @returns Interpolated scalar value
  37493. */
  37494. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37495. /**
  37496. * Interpolates a quaternion using a spherical linear interpolation
  37497. * @param startValue Start value of the animation curve
  37498. * @param endValue End value of the animation curve
  37499. * @param gradient Scalar amount to interpolate
  37500. * @returns Interpolated quaternion value
  37501. */
  37502. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37503. /**
  37504. * Interpolates a quaternion cubically
  37505. * @param startValue Start value of the animation curve
  37506. * @param outTangent End tangent of the animation curve
  37507. * @param endValue End value of the animation curve
  37508. * @param inTangent Start tangent of the animation curve
  37509. * @param gradient Scalar amount to interpolate
  37510. * @returns Interpolated quaternion value
  37511. */
  37512. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37513. /**
  37514. * Interpolates a Vector3 linearl
  37515. * @param startValue Start value of the animation curve
  37516. * @param endValue End value of the animation curve
  37517. * @param gradient Scalar amount to interpolate
  37518. * @returns Interpolated scalar value
  37519. */
  37520. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37521. /**
  37522. * Interpolates a Vector3 cubically
  37523. * @param startValue Start value of the animation curve
  37524. * @param outTangent End tangent of the animation
  37525. * @param endValue End value of the animation curve
  37526. * @param inTangent Start tangent of the animation curve
  37527. * @param gradient Scalar amount to interpolate
  37528. * @returns InterpolatedVector3 value
  37529. */
  37530. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37531. /**
  37532. * Interpolates a Vector2 linearly
  37533. * @param startValue Start value of the animation curve
  37534. * @param endValue End value of the animation curve
  37535. * @param gradient Scalar amount to interpolate
  37536. * @returns Interpolated Vector2 value
  37537. */
  37538. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37539. /**
  37540. * Interpolates a Vector2 cubically
  37541. * @param startValue Start value of the animation curve
  37542. * @param outTangent End tangent of the animation
  37543. * @param endValue End value of the animation curve
  37544. * @param inTangent Start tangent of the animation curve
  37545. * @param gradient Scalar amount to interpolate
  37546. * @returns Interpolated Vector2 value
  37547. */
  37548. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37549. /**
  37550. * Interpolates a size linearly
  37551. * @param startValue Start value of the animation curve
  37552. * @param endValue End value of the animation curve
  37553. * @param gradient Scalar amount to interpolate
  37554. * @returns Interpolated Size value
  37555. */
  37556. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37557. /**
  37558. * Interpolates a Color3 linearly
  37559. * @param startValue Start value of the animation curve
  37560. * @param endValue End value of the animation curve
  37561. * @param gradient Scalar amount to interpolate
  37562. * @returns Interpolated Color3 value
  37563. */
  37564. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37565. /**
  37566. * Interpolates a Color4 linearly
  37567. * @param startValue Start value of the animation curve
  37568. * @param endValue End value of the animation curve
  37569. * @param gradient Scalar amount to interpolate
  37570. * @returns Interpolated Color3 value
  37571. */
  37572. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37573. /**
  37574. * @hidden Internal use only
  37575. */
  37576. _getKeyValue(value: any): any;
  37577. /**
  37578. * @hidden Internal use only
  37579. */
  37580. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37581. /**
  37582. * Defines the function to use to interpolate matrices
  37583. * @param startValue defines the start matrix
  37584. * @param endValue defines the end matrix
  37585. * @param gradient defines the gradient between both matrices
  37586. * @param result defines an optional target matrix where to store the interpolation
  37587. * @returns the interpolated matrix
  37588. */
  37589. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37590. /**
  37591. * Makes a copy of the animation
  37592. * @returns Cloned animation
  37593. */
  37594. clone(): Animation;
  37595. /**
  37596. * Sets the key frames of the animation
  37597. * @param values The animation key frames to set
  37598. */
  37599. setKeys(values: Array<IAnimationKey>): void;
  37600. /**
  37601. * Serializes the animation to an object
  37602. * @returns Serialized object
  37603. */
  37604. serialize(): any;
  37605. /**
  37606. * Float animation type
  37607. */
  37608. static readonly ANIMATIONTYPE_FLOAT: number;
  37609. /**
  37610. * Vector3 animation type
  37611. */
  37612. static readonly ANIMATIONTYPE_VECTOR3: number;
  37613. /**
  37614. * Quaternion animation type
  37615. */
  37616. static readonly ANIMATIONTYPE_QUATERNION: number;
  37617. /**
  37618. * Matrix animation type
  37619. */
  37620. static readonly ANIMATIONTYPE_MATRIX: number;
  37621. /**
  37622. * Color3 animation type
  37623. */
  37624. static readonly ANIMATIONTYPE_COLOR3: number;
  37625. /**
  37626. * Color3 animation type
  37627. */
  37628. static readonly ANIMATIONTYPE_COLOR4: number;
  37629. /**
  37630. * Vector2 animation type
  37631. */
  37632. static readonly ANIMATIONTYPE_VECTOR2: number;
  37633. /**
  37634. * Size animation type
  37635. */
  37636. static readonly ANIMATIONTYPE_SIZE: number;
  37637. /**
  37638. * Relative Loop Mode
  37639. */
  37640. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37641. /**
  37642. * Cycle Loop Mode
  37643. */
  37644. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37645. /**
  37646. * Constant Loop Mode
  37647. */
  37648. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37649. /** @hidden */
  37650. static _UniversalLerp(left: any, right: any, amount: number): any;
  37651. /**
  37652. * Parses an animation object and creates an animation
  37653. * @param parsedAnimation Parsed animation object
  37654. * @returns Animation object
  37655. */
  37656. static Parse(parsedAnimation: any): Animation;
  37657. /**
  37658. * Appends the serialized animations from the source animations
  37659. * @param source Source containing the animations
  37660. * @param destination Target to store the animations
  37661. */
  37662. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37663. /**
  37664. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37665. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37666. * @param url defines the url to load from
  37667. * @returns a promise that will resolve to the new animation or an array of animations
  37668. */
  37669. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37670. /**
  37671. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37672. * @param snippetId defines the snippet to load
  37673. * @returns a promise that will resolve to the new animation or a new array of animations
  37674. */
  37675. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37676. }
  37677. }
  37678. declare module BABYLON {
  37679. /**
  37680. * Interface containing an array of animations
  37681. */
  37682. export interface IAnimatable {
  37683. /**
  37684. * Array of animations
  37685. */
  37686. animations: Nullable<Array<Animation>>;
  37687. }
  37688. }
  37689. declare module BABYLON {
  37690. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37691. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37692. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37693. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37694. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37695. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37696. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37697. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37698. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37699. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37700. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37701. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37702. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37703. /**
  37704. * Decorator used to define property that can be serialized as reference to a camera
  37705. * @param sourceName defines the name of the property to decorate
  37706. */
  37707. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37708. /**
  37709. * Class used to help serialization objects
  37710. */
  37711. export class SerializationHelper {
  37712. /** @hidden */
  37713. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37714. /** @hidden */
  37715. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37716. /** @hidden */
  37717. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37718. /** @hidden */
  37719. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37720. /**
  37721. * Appends the serialized animations from the source animations
  37722. * @param source Source containing the animations
  37723. * @param destination Target to store the animations
  37724. */
  37725. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37726. /**
  37727. * Static function used to serialized a specific entity
  37728. * @param entity defines the entity to serialize
  37729. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37730. * @returns a JSON compatible object representing the serialization of the entity
  37731. */
  37732. static Serialize<T>(entity: T, serializationObject?: any): any;
  37733. /**
  37734. * Creates a new entity from a serialization data object
  37735. * @param creationFunction defines a function used to instanciated the new entity
  37736. * @param source defines the source serialization data
  37737. * @param scene defines the hosting scene
  37738. * @param rootUrl defines the root url for resources
  37739. * @returns a new entity
  37740. */
  37741. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37742. /**
  37743. * Clones an object
  37744. * @param creationFunction defines the function used to instanciate the new object
  37745. * @param source defines the source object
  37746. * @returns the cloned object
  37747. */
  37748. static Clone<T>(creationFunction: () => T, source: T): T;
  37749. /**
  37750. * Instanciates a new object based on a source one (some data will be shared between both object)
  37751. * @param creationFunction defines the function used to instanciate the new object
  37752. * @param source defines the source object
  37753. * @returns the new object
  37754. */
  37755. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37756. }
  37757. }
  37758. declare module BABYLON {
  37759. /**
  37760. * This is the base class of all the camera used in the application.
  37761. * @see https://doc.babylonjs.com/features/cameras
  37762. */
  37763. export class Camera extends Node {
  37764. /** @hidden */
  37765. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  37766. /**
  37767. * This is the default projection mode used by the cameras.
  37768. * It helps recreating a feeling of perspective and better appreciate depth.
  37769. * This is the best way to simulate real life cameras.
  37770. */
  37771. static readonly PERSPECTIVE_CAMERA: number;
  37772. /**
  37773. * This helps creating camera with an orthographic mode.
  37774. * 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.
  37775. */
  37776. static readonly ORTHOGRAPHIC_CAMERA: number;
  37777. /**
  37778. * This is the default FOV mode for perspective cameras.
  37779. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37780. */
  37781. static readonly FOVMODE_VERTICAL_FIXED: number;
  37782. /**
  37783. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37784. */
  37785. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37786. /**
  37787. * This specifies ther is no need for a camera rig.
  37788. * Basically only one eye is rendered corresponding to the camera.
  37789. */
  37790. static readonly RIG_MODE_NONE: number;
  37791. /**
  37792. * Simulates a camera Rig with one blue eye and one red eye.
  37793. * This can be use with 3d blue and red glasses.
  37794. */
  37795. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37796. /**
  37797. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37798. */
  37799. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37800. /**
  37801. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37802. */
  37803. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37804. /**
  37805. * Defines that both eyes of the camera will be rendered over under each other.
  37806. */
  37807. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37808. /**
  37809. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37810. */
  37811. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37812. /**
  37813. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37814. */
  37815. static readonly RIG_MODE_VR: number;
  37816. /**
  37817. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37818. */
  37819. static readonly RIG_MODE_WEBVR: number;
  37820. /**
  37821. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37822. */
  37823. static readonly RIG_MODE_CUSTOM: number;
  37824. /**
  37825. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37826. */
  37827. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37828. /**
  37829. * Define the input manager associated with the camera.
  37830. */
  37831. inputs: CameraInputsManager<Camera>;
  37832. /** @hidden */
  37833. _position: Vector3;
  37834. /**
  37835. * Define the current local position of the camera in the scene
  37836. */
  37837. get position(): Vector3;
  37838. set position(newPosition: Vector3);
  37839. protected _upVector: Vector3;
  37840. /**
  37841. * The vector the camera should consider as up.
  37842. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37843. */
  37844. set upVector(vec: Vector3);
  37845. get upVector(): Vector3;
  37846. /**
  37847. * Define the current limit on the left side for an orthographic camera
  37848. * In scene unit
  37849. */
  37850. orthoLeft: Nullable<number>;
  37851. /**
  37852. * Define the current limit on the right side for an orthographic camera
  37853. * In scene unit
  37854. */
  37855. orthoRight: Nullable<number>;
  37856. /**
  37857. * Define the current limit on the bottom side for an orthographic camera
  37858. * In scene unit
  37859. */
  37860. orthoBottom: Nullable<number>;
  37861. /**
  37862. * Define the current limit on the top side for an orthographic camera
  37863. * In scene unit
  37864. */
  37865. orthoTop: Nullable<number>;
  37866. /**
  37867. * Field Of View is set in Radians. (default is 0.8)
  37868. */
  37869. fov: number;
  37870. /**
  37871. * Define the minimum distance the camera can see from.
  37872. * This is important to note that the depth buffer are not infinite and the closer it starts
  37873. * the more your scene might encounter depth fighting issue.
  37874. */
  37875. minZ: number;
  37876. /**
  37877. * Define the maximum distance the camera can see to.
  37878. * This is important to note that the depth buffer are not infinite and the further it end
  37879. * the more your scene might encounter depth fighting issue.
  37880. */
  37881. maxZ: number;
  37882. /**
  37883. * Define the default inertia of the camera.
  37884. * This helps giving a smooth feeling to the camera movement.
  37885. */
  37886. inertia: number;
  37887. /**
  37888. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37889. */
  37890. mode: number;
  37891. /**
  37892. * Define whether the camera is intermediate.
  37893. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37894. */
  37895. isIntermediate: boolean;
  37896. /**
  37897. * Define the viewport of the camera.
  37898. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37899. */
  37900. viewport: Viewport;
  37901. /**
  37902. * Restricts the camera to viewing objects with the same layerMask.
  37903. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37904. */
  37905. layerMask: number;
  37906. /**
  37907. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37908. */
  37909. fovMode: number;
  37910. /**
  37911. * Rig mode of the camera.
  37912. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37913. * This is normally controlled byt the camera themselves as internal use.
  37914. */
  37915. cameraRigMode: number;
  37916. /**
  37917. * Defines the distance between both "eyes" in case of a RIG
  37918. */
  37919. interaxialDistance: number;
  37920. /**
  37921. * Defines if stereoscopic rendering is done side by side or over under.
  37922. */
  37923. isStereoscopicSideBySide: boolean;
  37924. /**
  37925. * 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
  37926. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37927. * else in the scene. (Eg. security camera)
  37928. *
  37929. * 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)
  37930. */
  37931. customRenderTargets: RenderTargetTexture[];
  37932. /**
  37933. * When set, the camera will render to this render target instead of the default canvas
  37934. *
  37935. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37936. */
  37937. outputRenderTarget: Nullable<RenderTargetTexture>;
  37938. /**
  37939. * Observable triggered when the camera view matrix has changed.
  37940. */
  37941. onViewMatrixChangedObservable: Observable<Camera>;
  37942. /**
  37943. * Observable triggered when the camera Projection matrix has changed.
  37944. */
  37945. onProjectionMatrixChangedObservable: Observable<Camera>;
  37946. /**
  37947. * Observable triggered when the inputs have been processed.
  37948. */
  37949. onAfterCheckInputsObservable: Observable<Camera>;
  37950. /**
  37951. * Observable triggered when reset has been called and applied to the camera.
  37952. */
  37953. onRestoreStateObservable: Observable<Camera>;
  37954. /**
  37955. * Is this camera a part of a rig system?
  37956. */
  37957. isRigCamera: boolean;
  37958. /**
  37959. * If isRigCamera set to true this will be set with the parent camera.
  37960. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37961. */
  37962. rigParent?: Camera;
  37963. /** @hidden */
  37964. _cameraRigParams: any;
  37965. /** @hidden */
  37966. _rigCameras: Camera[];
  37967. /** @hidden */
  37968. _rigPostProcess: Nullable<PostProcess>;
  37969. protected _webvrViewMatrix: Matrix;
  37970. /** @hidden */
  37971. _skipRendering: boolean;
  37972. /** @hidden */
  37973. _projectionMatrix: Matrix;
  37974. /** @hidden */
  37975. _postProcesses: Nullable<PostProcess>[];
  37976. /** @hidden */
  37977. _activeMeshes: SmartArray<AbstractMesh>;
  37978. protected _globalPosition: Vector3;
  37979. /** @hidden */
  37980. _computedViewMatrix: Matrix;
  37981. private _doNotComputeProjectionMatrix;
  37982. private _transformMatrix;
  37983. private _frustumPlanes;
  37984. private _refreshFrustumPlanes;
  37985. private _storedFov;
  37986. private _stateStored;
  37987. /**
  37988. * Instantiates a new camera object.
  37989. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37990. * @see https://doc.babylonjs.com/features/cameras
  37991. * @param name Defines the name of the camera in the scene
  37992. * @param position Defines the position of the camera
  37993. * @param scene Defines the scene the camera belongs too
  37994. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  37995. */
  37996. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37997. /**
  37998. * Store current camera state (fov, position, etc..)
  37999. * @returns the camera
  38000. */
  38001. storeState(): Camera;
  38002. /**
  38003. * Restores the camera state values if it has been stored. You must call storeState() first
  38004. */
  38005. protected _restoreStateValues(): boolean;
  38006. /**
  38007. * Restored camera state. You must call storeState() first.
  38008. * @returns true if restored and false otherwise
  38009. */
  38010. restoreState(): boolean;
  38011. /**
  38012. * Gets the class name of the camera.
  38013. * @returns the class name
  38014. */
  38015. getClassName(): string;
  38016. /** @hidden */
  38017. readonly _isCamera: boolean;
  38018. /**
  38019. * Gets a string representation of the camera useful for debug purpose.
  38020. * @param fullDetails Defines that a more verboe level of logging is required
  38021. * @returns the string representation
  38022. */
  38023. toString(fullDetails?: boolean): string;
  38024. /**
  38025. * Gets the current world space position of the camera.
  38026. */
  38027. get globalPosition(): Vector3;
  38028. /**
  38029. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38030. * @returns the active meshe list
  38031. */
  38032. getActiveMeshes(): SmartArray<AbstractMesh>;
  38033. /**
  38034. * Check whether a mesh is part of the current active mesh list of the camera
  38035. * @param mesh Defines the mesh to check
  38036. * @returns true if active, false otherwise
  38037. */
  38038. isActiveMesh(mesh: Mesh): boolean;
  38039. /**
  38040. * Is this camera ready to be used/rendered
  38041. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38042. * @return true if the camera is ready
  38043. */
  38044. isReady(completeCheck?: boolean): boolean;
  38045. /** @hidden */
  38046. _initCache(): void;
  38047. /** @hidden */
  38048. _updateCache(ignoreParentClass?: boolean): void;
  38049. /** @hidden */
  38050. _isSynchronized(): boolean;
  38051. /** @hidden */
  38052. _isSynchronizedViewMatrix(): boolean;
  38053. /** @hidden */
  38054. _isSynchronizedProjectionMatrix(): boolean;
  38055. /**
  38056. * Attach the input controls to a specific dom element to get the input from.
  38057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38058. */
  38059. attachControl(noPreventDefault?: boolean): void;
  38060. /**
  38061. * Attach the input controls to a specific dom element to get the input from.
  38062. * @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
  38063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38064. * BACK COMPAT SIGNATURE ONLY.
  38065. */
  38066. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38067. /**
  38068. * Detach the current controls from the specified dom element.
  38069. */
  38070. detachControl(): void;
  38071. /**
  38072. * Detach the current controls from the specified dom element.
  38073. * @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
  38074. */
  38075. detachControl(ignored: any): void;
  38076. /**
  38077. * Update the camera state according to the different inputs gathered during the frame.
  38078. */
  38079. update(): void;
  38080. /** @hidden */
  38081. _checkInputs(): void;
  38082. /** @hidden */
  38083. get rigCameras(): Camera[];
  38084. /**
  38085. * Gets the post process used by the rig cameras
  38086. */
  38087. get rigPostProcess(): Nullable<PostProcess>;
  38088. /**
  38089. * Internal, gets the first post proces.
  38090. * @returns the first post process to be run on this camera.
  38091. */
  38092. _getFirstPostProcess(): Nullable<PostProcess>;
  38093. private _cascadePostProcessesToRigCams;
  38094. /**
  38095. * Attach a post process to the camera.
  38096. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38097. * @param postProcess The post process to attach to the camera
  38098. * @param insertAt The position of the post process in case several of them are in use in the scene
  38099. * @returns the position the post process has been inserted at
  38100. */
  38101. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38102. /**
  38103. * Detach a post process to the camera.
  38104. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38105. * @param postProcess The post process to detach from the camera
  38106. */
  38107. detachPostProcess(postProcess: PostProcess): void;
  38108. /**
  38109. * Gets the current world matrix of the camera
  38110. */
  38111. getWorldMatrix(): Matrix;
  38112. /** @hidden */
  38113. _getViewMatrix(): Matrix;
  38114. /**
  38115. * Gets the current view matrix of the camera.
  38116. * @param force forces the camera to recompute the matrix without looking at the cached state
  38117. * @returns the view matrix
  38118. */
  38119. getViewMatrix(force?: boolean): Matrix;
  38120. /**
  38121. * Freeze the projection matrix.
  38122. * It will prevent the cache check of the camera projection compute and can speed up perf
  38123. * if no parameter of the camera are meant to change
  38124. * @param projection Defines manually a projection if necessary
  38125. */
  38126. freezeProjectionMatrix(projection?: Matrix): void;
  38127. /**
  38128. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38129. */
  38130. unfreezeProjectionMatrix(): void;
  38131. /**
  38132. * Gets the current projection matrix of the camera.
  38133. * @param force forces the camera to recompute the matrix without looking at the cached state
  38134. * @returns the projection matrix
  38135. */
  38136. getProjectionMatrix(force?: boolean): Matrix;
  38137. /**
  38138. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38139. * @returns a Matrix
  38140. */
  38141. getTransformationMatrix(): Matrix;
  38142. private _updateFrustumPlanes;
  38143. /**
  38144. * Checks if a cullable object (mesh...) is in the camera frustum
  38145. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38146. * @param target The object to check
  38147. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38148. * @returns true if the object is in frustum otherwise false
  38149. */
  38150. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38151. /**
  38152. * Checks if a cullable object (mesh...) is in the camera frustum
  38153. * Unlike isInFrustum this cheks the full bounding box
  38154. * @param target The object to check
  38155. * @returns true if the object is in frustum otherwise false
  38156. */
  38157. isCompletelyInFrustum(target: ICullable): boolean;
  38158. /**
  38159. * Gets a ray in the forward direction from the camera.
  38160. * @param length Defines the length of the ray to create
  38161. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38162. * @param origin Defines the start point of the ray which defaults to the camera position
  38163. * @returns the forward ray
  38164. */
  38165. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38166. /**
  38167. * Gets a ray in the forward direction from the camera.
  38168. * @param refRay the ray to (re)use when setting the values
  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. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38175. /**
  38176. * Releases resources associated with this node.
  38177. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38178. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38179. */
  38180. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38181. /** @hidden */
  38182. _isLeftCamera: boolean;
  38183. /**
  38184. * Gets the left camera of a rig setup in case of Rigged Camera
  38185. */
  38186. get isLeftCamera(): boolean;
  38187. /** @hidden */
  38188. _isRightCamera: boolean;
  38189. /**
  38190. * Gets the right camera of a rig setup in case of Rigged Camera
  38191. */
  38192. get isRightCamera(): boolean;
  38193. /**
  38194. * Gets the left camera of a rig setup in case of Rigged Camera
  38195. */
  38196. get leftCamera(): Nullable<FreeCamera>;
  38197. /**
  38198. * Gets the right camera of a rig setup in case of Rigged Camera
  38199. */
  38200. get rightCamera(): Nullable<FreeCamera>;
  38201. /**
  38202. * Gets the left camera target of a rig setup in case of Rigged Camera
  38203. * @returns the target position
  38204. */
  38205. getLeftTarget(): Nullable<Vector3>;
  38206. /**
  38207. * Gets the right camera target of a rig setup in case of Rigged Camera
  38208. * @returns the target position
  38209. */
  38210. getRightTarget(): Nullable<Vector3>;
  38211. /**
  38212. * @hidden
  38213. */
  38214. setCameraRigMode(mode: number, rigParams: any): void;
  38215. /** @hidden */
  38216. static _setStereoscopicRigMode(camera: Camera): void;
  38217. /** @hidden */
  38218. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38219. /** @hidden */
  38220. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38221. /** @hidden */
  38222. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38223. /** @hidden */
  38224. _getVRProjectionMatrix(): Matrix;
  38225. protected _updateCameraRotationMatrix(): void;
  38226. protected _updateWebVRCameraRotationMatrix(): void;
  38227. /**
  38228. * This function MUST be overwritten by the different WebVR cameras available.
  38229. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38230. * @hidden
  38231. */
  38232. _getWebVRProjectionMatrix(): Matrix;
  38233. /**
  38234. * This function MUST be overwritten by the different WebVR cameras available.
  38235. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38236. * @hidden
  38237. */
  38238. _getWebVRViewMatrix(): Matrix;
  38239. /** @hidden */
  38240. setCameraRigParameter(name: string, value: any): void;
  38241. /**
  38242. * needs to be overridden by children so sub has required properties to be copied
  38243. * @hidden
  38244. */
  38245. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38246. /**
  38247. * May need to be overridden by children
  38248. * @hidden
  38249. */
  38250. _updateRigCameras(): void;
  38251. /** @hidden */
  38252. _setupInputs(): void;
  38253. /**
  38254. * Serialiaze the camera setup to a json represention
  38255. * @returns the JSON representation
  38256. */
  38257. serialize(): any;
  38258. /**
  38259. * Clones the current camera.
  38260. * @param name The cloned camera name
  38261. * @returns the cloned camera
  38262. */
  38263. clone(name: string): Camera;
  38264. /**
  38265. * Gets the direction of the camera relative to a given local axis.
  38266. * @param localAxis Defines the reference axis to provide a relative direction.
  38267. * @return the direction
  38268. */
  38269. getDirection(localAxis: Vector3): Vector3;
  38270. /**
  38271. * Returns the current camera absolute rotation
  38272. */
  38273. get absoluteRotation(): Quaternion;
  38274. /**
  38275. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38276. * @param localAxis Defines the reference axis to provide a relative direction.
  38277. * @param result Defines the vector to store the result in
  38278. */
  38279. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38280. /**
  38281. * Gets a camera constructor for a given camera type
  38282. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38283. * @param name The name of the camera the result will be able to instantiate
  38284. * @param scene The scene the result will construct the camera in
  38285. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38286. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38287. * @returns a factory method to construc the camera
  38288. */
  38289. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38290. /**
  38291. * Compute the world matrix of the camera.
  38292. * @returns the camera world matrix
  38293. */
  38294. computeWorldMatrix(): Matrix;
  38295. /**
  38296. * Parse a JSON and creates the camera from the parsed information
  38297. * @param parsedCamera The JSON to parse
  38298. * @param scene The scene to instantiate the camera in
  38299. * @returns the newly constructed camera
  38300. */
  38301. static Parse(parsedCamera: any, scene: Scene): Camera;
  38302. }
  38303. }
  38304. declare module BABYLON {
  38305. /**
  38306. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38307. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38308. */
  38309. export class PostProcessManager {
  38310. private _scene;
  38311. private _indexBuffer;
  38312. private _vertexBuffers;
  38313. /**
  38314. * Creates a new instance PostProcess
  38315. * @param scene The scene that the post process is associated with.
  38316. */
  38317. constructor(scene: Scene);
  38318. private _prepareBuffers;
  38319. private _buildIndexBuffer;
  38320. /**
  38321. * Rebuilds the vertex buffers of the manager.
  38322. * @hidden
  38323. */
  38324. _rebuild(): void;
  38325. /**
  38326. * Prepares a frame to be run through a post process.
  38327. * @param sourceTexture The input texture to the post procesess. (default: null)
  38328. * @param postProcesses An array of post processes to be run. (default: null)
  38329. * @returns True if the post processes were able to be run.
  38330. * @hidden
  38331. */
  38332. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38333. /**
  38334. * Manually render a set of post processes to a texture.
  38335. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38336. * @param postProcesses An array of post processes to be run.
  38337. * @param targetTexture The target texture to render to.
  38338. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38339. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38340. * @param lodLevel defines which lod of the texture to render to
  38341. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38342. */
  38343. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38344. /**
  38345. * Finalize the result of the output of the postprocesses.
  38346. * @param doNotPresent If true the result will not be displayed to the screen.
  38347. * @param targetTexture The target texture to render to.
  38348. * @param faceIndex The index of the face to bind the target texture to.
  38349. * @param postProcesses The array of post processes to render.
  38350. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38351. * @hidden
  38352. */
  38353. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38354. /**
  38355. * Disposes of the post process manager.
  38356. */
  38357. dispose(): void;
  38358. }
  38359. }
  38360. declare module BABYLON {
  38361. /**
  38362. * This Helps creating a texture that will be created from a camera in your scene.
  38363. * It is basically a dynamic texture that could be used to create special effects for instance.
  38364. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38365. */
  38366. export class RenderTargetTexture extends Texture {
  38367. /**
  38368. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38369. */
  38370. static readonly REFRESHRATE_RENDER_ONCE: number;
  38371. /**
  38372. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  38373. */
  38374. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38375. /**
  38376. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38377. * the central point of your effect and can save a lot of performances.
  38378. */
  38379. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38380. /**
  38381. * Use this predicate to dynamically define the list of mesh you want to render.
  38382. * If set, the renderList property will be overwritten.
  38383. */
  38384. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38385. private _renderList;
  38386. /**
  38387. * Use this list to define the list of mesh you want to render.
  38388. */
  38389. get renderList(): Nullable<Array<AbstractMesh>>;
  38390. set renderList(value: Nullable<Array<AbstractMesh>>);
  38391. /**
  38392. * Use this function to overload the renderList array at rendering time.
  38393. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  38394. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38395. * the cube (if the RTT is a cube, else layerOrFace=0).
  38396. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38397. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38398. * hold dummy elements!
  38399. */
  38400. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38401. private _hookArray;
  38402. /**
  38403. * Define if particles should be rendered in your texture.
  38404. */
  38405. renderParticles: boolean;
  38406. /**
  38407. * Define if sprites should be rendered in your texture.
  38408. */
  38409. renderSprites: boolean;
  38410. /**
  38411. * Define the camera used to render the texture.
  38412. */
  38413. activeCamera: Nullable<Camera>;
  38414. /**
  38415. * Override the mesh isReady function with your own one.
  38416. */
  38417. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38418. /**
  38419. * Override the render function of the texture with your own one.
  38420. */
  38421. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38422. /**
  38423. * Define if camera post processes should be use while rendering the texture.
  38424. */
  38425. useCameraPostProcesses: boolean;
  38426. /**
  38427. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38428. */
  38429. ignoreCameraViewport: boolean;
  38430. private _postProcessManager;
  38431. private _postProcesses;
  38432. private _resizeObserver;
  38433. /**
  38434. * An event triggered when the texture is unbind.
  38435. */
  38436. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38437. /**
  38438. * An event triggered when the texture is unbind.
  38439. */
  38440. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38441. private _onAfterUnbindObserver;
  38442. /**
  38443. * Set a after unbind callback in the texture.
  38444. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38445. */
  38446. set onAfterUnbind(callback: () => void);
  38447. /**
  38448. * An event triggered before rendering the texture
  38449. */
  38450. onBeforeRenderObservable: Observable<number>;
  38451. private _onBeforeRenderObserver;
  38452. /**
  38453. * Set a before render callback in the texture.
  38454. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38455. */
  38456. set onBeforeRender(callback: (faceIndex: number) => void);
  38457. /**
  38458. * An event triggered after rendering the texture
  38459. */
  38460. onAfterRenderObservable: Observable<number>;
  38461. private _onAfterRenderObserver;
  38462. /**
  38463. * Set a after render callback in the texture.
  38464. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38465. */
  38466. set onAfterRender(callback: (faceIndex: number) => void);
  38467. /**
  38468. * An event triggered after the texture clear
  38469. */
  38470. onClearObservable: Observable<Engine>;
  38471. private _onClearObserver;
  38472. /**
  38473. * Set a clear callback in the texture.
  38474. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38475. */
  38476. set onClear(callback: (Engine: Engine) => void);
  38477. /**
  38478. * An event triggered when the texture is resized.
  38479. */
  38480. onResizeObservable: Observable<RenderTargetTexture>;
  38481. /**
  38482. * Define the clear color of the Render Target if it should be different from the scene.
  38483. */
  38484. clearColor: Color4;
  38485. protected _size: number | {
  38486. width: number;
  38487. height: number;
  38488. layers?: number;
  38489. };
  38490. protected _initialSizeParameter: number | {
  38491. width: number;
  38492. height: number;
  38493. } | {
  38494. ratio: number;
  38495. };
  38496. protected _sizeRatio: Nullable<number>;
  38497. /** @hidden */
  38498. _generateMipMaps: boolean;
  38499. protected _renderingManager: RenderingManager;
  38500. /** @hidden */
  38501. _waitingRenderList?: string[];
  38502. protected _doNotChangeAspectRatio: boolean;
  38503. protected _currentRefreshId: number;
  38504. protected _refreshRate: number;
  38505. protected _textureMatrix: Matrix;
  38506. protected _samples: number;
  38507. protected _renderTargetOptions: RenderTargetCreationOptions;
  38508. /**
  38509. * Gets render target creation options that were used.
  38510. */
  38511. get renderTargetOptions(): RenderTargetCreationOptions;
  38512. protected _onRatioRescale(): void;
  38513. /**
  38514. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38515. * It must define where the camera used to render the texture is set
  38516. */
  38517. boundingBoxPosition: Vector3;
  38518. private _boundingBoxSize;
  38519. /**
  38520. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38521. * When defined, the cubemap will switch to local mode
  38522. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38523. * @example https://www.babylonjs-playground.com/#RNASML
  38524. */
  38525. set boundingBoxSize(value: Vector3);
  38526. get boundingBoxSize(): Vector3;
  38527. /**
  38528. * In case the RTT has been created with a depth texture, get the associated
  38529. * depth texture.
  38530. * Otherwise, return null.
  38531. */
  38532. get depthStencilTexture(): Nullable<InternalTexture>;
  38533. /**
  38534. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  38535. * or used a shadow, depth texture...
  38536. * @param name The friendly name of the texture
  38537. * @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)
  38538. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38539. * @param generateMipMaps True if mip maps need to be generated after render.
  38540. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38541. * @param type The type of the buffer in the RTT (int, half float, float...)
  38542. * @param isCube True if a cube texture needs to be created
  38543. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38544. * @param generateDepthBuffer True to generate a depth buffer
  38545. * @param generateStencilBuffer True to generate a stencil buffer
  38546. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38547. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38548. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38549. * @param samples sample count to use when creating the RTT
  38550. */
  38551. constructor(name: string, size: number | {
  38552. width: number;
  38553. height: number;
  38554. layers?: number;
  38555. } | {
  38556. ratio: number;
  38557. }, 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);
  38558. /**
  38559. * Creates a depth stencil texture.
  38560. * This is only available in WebGL 2 or with the depth texture extension available.
  38561. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38562. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38563. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38564. * @param samples sample count of the depth/stencil texture
  38565. */
  38566. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38567. private _processSizeParameter;
  38568. /**
  38569. * Define the number of samples to use in case of MSAA.
  38570. * It defaults to one meaning no MSAA has been enabled.
  38571. */
  38572. get samples(): number;
  38573. set samples(value: number);
  38574. /**
  38575. * Resets the refresh counter of the texture and start bak from scratch.
  38576. * Could be useful to regenerate the texture if it is setup to render only once.
  38577. */
  38578. resetRefreshCounter(): void;
  38579. /**
  38580. * Define the refresh rate of the texture or the rendering frequency.
  38581. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38582. */
  38583. get refreshRate(): number;
  38584. set refreshRate(value: number);
  38585. /**
  38586. * Adds a post process to the render target rendering passes.
  38587. * @param postProcess define the post process to add
  38588. */
  38589. addPostProcess(postProcess: PostProcess): void;
  38590. /**
  38591. * Clear all the post processes attached to the render target
  38592. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  38593. */
  38594. clearPostProcesses(dispose?: boolean): void;
  38595. /**
  38596. * Remove one of the post process from the list of attached post processes to the texture
  38597. * @param postProcess define the post process to remove from the list
  38598. */
  38599. removePostProcess(postProcess: PostProcess): void;
  38600. /** @hidden */
  38601. _shouldRender(): boolean;
  38602. /**
  38603. * Gets the actual render size of the texture.
  38604. * @returns the width of the render size
  38605. */
  38606. getRenderSize(): number;
  38607. /**
  38608. * Gets the actual render width of the texture.
  38609. * @returns the width of the render size
  38610. */
  38611. getRenderWidth(): number;
  38612. /**
  38613. * Gets the actual render height of the texture.
  38614. * @returns the height of the render size
  38615. */
  38616. getRenderHeight(): number;
  38617. /**
  38618. * Gets the actual number of layers of the texture.
  38619. * @returns the number of layers
  38620. */
  38621. getRenderLayers(): number;
  38622. /**
  38623. * Get if the texture can be rescaled or not.
  38624. */
  38625. get canRescale(): boolean;
  38626. /**
  38627. * Resize the texture using a ratio.
  38628. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  38629. */
  38630. scale(ratio: number): void;
  38631. /**
  38632. * Get the texture reflection matrix used to rotate/transform the reflection.
  38633. * @returns the reflection matrix
  38634. */
  38635. getReflectionTextureMatrix(): Matrix;
  38636. /**
  38637. * Resize the texture to a new desired size.
  38638. * Be carrefull as it will recreate all the data in the new texture.
  38639. * @param size Define the new size. It can be:
  38640. * - a number for squared texture,
  38641. * - an object containing { width: number, height: number }
  38642. * - or an object containing a ratio { ratio: number }
  38643. */
  38644. resize(size: number | {
  38645. width: number;
  38646. height: number;
  38647. } | {
  38648. ratio: number;
  38649. }): void;
  38650. private _defaultRenderListPrepared;
  38651. /**
  38652. * Renders all the objects from the render list into the texture.
  38653. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  38654. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  38655. */
  38656. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38657. private _bestReflectionRenderTargetDimension;
  38658. private _prepareRenderingManager;
  38659. /**
  38660. * @hidden
  38661. * @param faceIndex face index to bind to if this is a cubetexture
  38662. * @param layer defines the index of the texture to bind in the array
  38663. */
  38664. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  38665. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38666. private renderToTarget;
  38667. /**
  38668. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38669. * This allowed control for front to back rendering or reversly depending of the special needs.
  38670. *
  38671. * @param renderingGroupId The rendering group id corresponding to its index
  38672. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38673. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38674. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38675. */
  38676. 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;
  38677. /**
  38678. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38679. *
  38680. * @param renderingGroupId The rendering group id corresponding to its index
  38681. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38682. */
  38683. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  38684. /**
  38685. * Clones the texture.
  38686. * @returns the cloned texture
  38687. */
  38688. clone(): RenderTargetTexture;
  38689. /**
  38690. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  38691. * @returns The JSON representation of the texture
  38692. */
  38693. serialize(): any;
  38694. /**
  38695. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  38696. */
  38697. disposeFramebufferObjects(): void;
  38698. /**
  38699. * Dispose the texture and release its associated resources.
  38700. */
  38701. dispose(): void;
  38702. /** @hidden */
  38703. _rebuild(): void;
  38704. /**
  38705. * Clear the info related to rendering groups preventing retention point in material dispose.
  38706. */
  38707. freeRenderingGroups(): void;
  38708. /**
  38709. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  38710. * @returns the view count
  38711. */
  38712. getViewCount(): number;
  38713. }
  38714. }
  38715. declare module BABYLON {
  38716. /**
  38717. * Options to be used when creating an effect.
  38718. */
  38719. export interface IEffectCreationOptions {
  38720. /**
  38721. * Atrributes that will be used in the shader.
  38722. */
  38723. attributes: string[];
  38724. /**
  38725. * Uniform varible names that will be set in the shader.
  38726. */
  38727. uniformsNames: string[];
  38728. /**
  38729. * Uniform buffer variable names that will be set in the shader.
  38730. */
  38731. uniformBuffersNames: string[];
  38732. /**
  38733. * Sampler texture variable names that will be set in the shader.
  38734. */
  38735. samplers: string[];
  38736. /**
  38737. * Define statements that will be set in the shader.
  38738. */
  38739. defines: any;
  38740. /**
  38741. * Possible fallbacks for this effect to improve performance when needed.
  38742. */
  38743. fallbacks: Nullable<IEffectFallbacks>;
  38744. /**
  38745. * Callback that will be called when the shader is compiled.
  38746. */
  38747. onCompiled: Nullable<(effect: Effect) => void>;
  38748. /**
  38749. * Callback that will be called if an error occurs during shader compilation.
  38750. */
  38751. onError: Nullable<(effect: Effect, errors: string) => void>;
  38752. /**
  38753. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38754. */
  38755. indexParameters?: any;
  38756. /**
  38757. * Max number of lights that can be used in the shader.
  38758. */
  38759. maxSimultaneousLights?: number;
  38760. /**
  38761. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38762. */
  38763. transformFeedbackVaryings?: Nullable<string[]>;
  38764. /**
  38765. * 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
  38766. */
  38767. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38768. /**
  38769. * Is this effect rendering to several color attachments ?
  38770. */
  38771. multiTarget?: boolean;
  38772. }
  38773. /**
  38774. * Effect containing vertex and fragment shader that can be executed on an object.
  38775. */
  38776. export class Effect implements IDisposable {
  38777. /**
  38778. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38779. */
  38780. static ShadersRepository: string;
  38781. /**
  38782. * Enable logging of the shader code when a compilation error occurs
  38783. */
  38784. static LogShaderCodeOnCompilationError: boolean;
  38785. /**
  38786. * Name of the effect.
  38787. */
  38788. name: any;
  38789. /**
  38790. * String container all the define statements that should be set on the shader.
  38791. */
  38792. defines: string;
  38793. /**
  38794. * Callback that will be called when the shader is compiled.
  38795. */
  38796. onCompiled: Nullable<(effect: Effect) => void>;
  38797. /**
  38798. * Callback that will be called if an error occurs during shader compilation.
  38799. */
  38800. onError: Nullable<(effect: Effect, errors: string) => void>;
  38801. /**
  38802. * Callback that will be called when effect is bound.
  38803. */
  38804. onBind: Nullable<(effect: Effect) => void>;
  38805. /**
  38806. * Unique ID of the effect.
  38807. */
  38808. uniqueId: number;
  38809. /**
  38810. * Observable that will be called when the shader is compiled.
  38811. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38812. */
  38813. onCompileObservable: Observable<Effect>;
  38814. /**
  38815. * Observable that will be called if an error occurs during shader compilation.
  38816. */
  38817. onErrorObservable: Observable<Effect>;
  38818. /** @hidden */
  38819. _onBindObservable: Nullable<Observable<Effect>>;
  38820. /**
  38821. * @hidden
  38822. * Specifies if the effect was previously ready
  38823. */
  38824. _wasPreviouslyReady: boolean;
  38825. /**
  38826. * Observable that will be called when effect is bound.
  38827. */
  38828. get onBindObservable(): Observable<Effect>;
  38829. /** @hidden */
  38830. _bonesComputationForcedToCPU: boolean;
  38831. /** @hidden */
  38832. _uniformBuffersNames: {
  38833. [key: string]: number;
  38834. };
  38835. /** @hidden */
  38836. _samplerList: string[];
  38837. /** @hidden */
  38838. _multiTarget: boolean;
  38839. private static _uniqueIdSeed;
  38840. private _engine;
  38841. private _uniformBuffersNamesList;
  38842. private _uniformsNames;
  38843. private _samplers;
  38844. private _isReady;
  38845. private _compilationError;
  38846. private _allFallbacksProcessed;
  38847. private _attributesNames;
  38848. private _attributes;
  38849. private _attributeLocationByName;
  38850. private _uniforms;
  38851. /**
  38852. * Key for the effect.
  38853. * @hidden
  38854. */
  38855. _key: string;
  38856. private _indexParameters;
  38857. private _fallbacks;
  38858. private _vertexSourceCodeOverride;
  38859. private _fragmentSourceCodeOverride;
  38860. private _transformFeedbackVaryings;
  38861. /**
  38862. * Compiled shader to webGL program.
  38863. * @hidden
  38864. */
  38865. _pipelineContext: Nullable<IPipelineContext>;
  38866. /** @hidden */
  38867. _vertexSourceCode: string;
  38868. /** @hidden */
  38869. _fragmentSourceCode: string;
  38870. /** @hidden */
  38871. private _rawVertexSourceCode;
  38872. /** @hidden */
  38873. private _rawFragmentSourceCode;
  38874. private static _baseCache;
  38875. private _processingContext;
  38876. /**
  38877. * Instantiates an effect.
  38878. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38879. * @param baseName Name of the effect.
  38880. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38881. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38882. * @param samplers List of sampler variables that will be passed to the shader.
  38883. * @param engine Engine to be used to render the effect
  38884. * @param defines Define statements to be added to the shader.
  38885. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38886. * @param onCompiled Callback that will be called when the shader is compiled.
  38887. * @param onError Callback that will be called if an error occurs during shader compilation.
  38888. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38889. * @param key Effect Key identifying uniquely compiled shader variants
  38890. */
  38891. 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);
  38892. private _useFinalCode;
  38893. /**
  38894. * Unique key for this effect
  38895. */
  38896. get key(): string;
  38897. /**
  38898. * If the effect has been compiled and prepared.
  38899. * @returns if the effect is compiled and prepared.
  38900. */
  38901. isReady(): boolean;
  38902. private _isReadyInternal;
  38903. /**
  38904. * The engine the effect was initialized with.
  38905. * @returns the engine.
  38906. */
  38907. getEngine(): Engine;
  38908. /**
  38909. * The pipeline context for this effect
  38910. * @returns the associated pipeline context
  38911. */
  38912. getPipelineContext(): Nullable<IPipelineContext>;
  38913. /**
  38914. * The set of names of attribute variables for the shader.
  38915. * @returns An array of attribute names.
  38916. */
  38917. getAttributesNames(): string[];
  38918. /**
  38919. * Returns the attribute at the given index.
  38920. * @param index The index of the attribute.
  38921. * @returns The location of the attribute.
  38922. */
  38923. getAttributeLocation(index: number): number;
  38924. /**
  38925. * Returns the attribute based on the name of the variable.
  38926. * @param name of the attribute to look up.
  38927. * @returns the attribute location.
  38928. */
  38929. getAttributeLocationByName(name: string): number;
  38930. /**
  38931. * The number of attributes.
  38932. * @returns the numnber of attributes.
  38933. */
  38934. getAttributesCount(): number;
  38935. /**
  38936. * Gets the index of a uniform variable.
  38937. * @param uniformName of the uniform to look up.
  38938. * @returns the index.
  38939. */
  38940. getUniformIndex(uniformName: string): number;
  38941. /**
  38942. * Returns the attribute based on the name of the variable.
  38943. * @param uniformName of the uniform to look up.
  38944. * @returns the location of the uniform.
  38945. */
  38946. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38947. /**
  38948. * Returns an array of sampler variable names
  38949. * @returns The array of sampler variable names.
  38950. */
  38951. getSamplers(): string[];
  38952. /**
  38953. * Returns an array of uniform variable names
  38954. * @returns The array of uniform variable names.
  38955. */
  38956. getUniformNames(): string[];
  38957. /**
  38958. * Returns an array of uniform buffer variable names
  38959. * @returns The array of uniform buffer variable names.
  38960. */
  38961. getUniformBuffersNames(): string[];
  38962. /**
  38963. * Returns the index parameters used to create the effect
  38964. * @returns The index parameters object
  38965. */
  38966. getIndexParameters(): any;
  38967. /**
  38968. * The error from the last compilation.
  38969. * @returns the error string.
  38970. */
  38971. getCompilationError(): string;
  38972. /**
  38973. * Gets a boolean indicating that all fallbacks were used during compilation
  38974. * @returns true if all fallbacks were used
  38975. */
  38976. allFallbacksProcessed(): boolean;
  38977. /**
  38978. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38979. * @param func The callback to be used.
  38980. */
  38981. executeWhenCompiled(func: (effect: Effect) => void): void;
  38982. private _checkIsReady;
  38983. private _loadShader;
  38984. /**
  38985. * Gets the vertex shader source code of this effect
  38986. */
  38987. get vertexSourceCode(): string;
  38988. /**
  38989. * Gets the fragment shader source code of this effect
  38990. */
  38991. get fragmentSourceCode(): string;
  38992. /**
  38993. * Gets the vertex shader source code before it has been processed by the preprocessor
  38994. */
  38995. get rawVertexSourceCode(): string;
  38996. /**
  38997. * Gets the fragment shader source code before it has been processed by the preprocessor
  38998. */
  38999. get rawFragmentSourceCode(): string;
  39000. /**
  39001. * Recompiles the webGL program
  39002. * @param vertexSourceCode The source code for the vertex shader.
  39003. * @param fragmentSourceCode The source code for the fragment shader.
  39004. * @param onCompiled Callback called when completed.
  39005. * @param onError Callback called on error.
  39006. * @hidden
  39007. */
  39008. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39009. /**
  39010. * Prepares the effect
  39011. * @hidden
  39012. */
  39013. _prepareEffect(): void;
  39014. private _getShaderCodeAndErrorLine;
  39015. private _processCompilationErrors;
  39016. /**
  39017. * Checks if the effect is supported. (Must be called after compilation)
  39018. */
  39019. get isSupported(): boolean;
  39020. /**
  39021. * Binds a texture to the engine to be used as output of the shader.
  39022. * @param channel Name of the output variable.
  39023. * @param texture Texture to bind.
  39024. * @hidden
  39025. */
  39026. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39027. /**
  39028. * Sets a texture on the engine to be used in the shader.
  39029. * @param channel Name of the sampler variable.
  39030. * @param texture Texture to set.
  39031. */
  39032. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39033. /**
  39034. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39035. * @param channel Name of the sampler variable.
  39036. * @param texture Texture to set.
  39037. */
  39038. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39039. /**
  39040. * Sets an array of textures on the engine to be used in the shader.
  39041. * @param channel Name of the variable.
  39042. * @param textures Textures to set.
  39043. */
  39044. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39045. /**
  39046. * 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)
  39047. * @param channel Name of the sampler variable.
  39048. * @param postProcess Post process to get the input texture from.
  39049. */
  39050. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39051. /**
  39052. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39053. * 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)
  39054. * @param channel Name of the sampler variable.
  39055. * @param postProcess Post process to get the output texture from.
  39056. */
  39057. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39058. /**
  39059. * Binds a buffer to a uniform.
  39060. * @param buffer Buffer to bind.
  39061. * @param name Name of the uniform variable to bind to.
  39062. */
  39063. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39064. /**
  39065. * Binds block to a uniform.
  39066. * @param blockName Name of the block to bind.
  39067. * @param index Index to bind.
  39068. */
  39069. bindUniformBlock(blockName: string, index: number): void;
  39070. /**
  39071. * Sets an interger value on a uniform variable.
  39072. * @param uniformName Name of the variable.
  39073. * @param value Value to be set.
  39074. * @returns this effect.
  39075. */
  39076. setInt(uniformName: string, value: number): Effect;
  39077. /**
  39078. * Sets an int2 value on a uniform variable.
  39079. * @param uniformName Name of the variable.
  39080. * @param x First int in int2.
  39081. * @param y Second int in int2.
  39082. * @returns this effect.
  39083. */
  39084. setInt2(uniformName: string, x: number, y: number): Effect;
  39085. /**
  39086. * Sets an int3 value on a uniform variable.
  39087. * @param uniformName Name of the variable.
  39088. * @param x First int in int3.
  39089. * @param y Second int in int3.
  39090. * @param z Third int in int3.
  39091. * @returns this effect.
  39092. */
  39093. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39094. /**
  39095. * Sets an int4 value on a uniform variable.
  39096. * @param uniformName Name of the variable.
  39097. * @param x First int in int4.
  39098. * @param y Second int in int4.
  39099. * @param z Third int in int4.
  39100. * @param w Fourth int in int4.
  39101. * @returns this effect.
  39102. */
  39103. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39104. /**
  39105. * Sets an int array on a uniform variable.
  39106. * @param uniformName Name of the variable.
  39107. * @param array array to be set.
  39108. * @returns this effect.
  39109. */
  39110. setIntArray(uniformName: string, array: Int32Array): Effect;
  39111. /**
  39112. * 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)
  39113. * @param uniformName Name of the variable.
  39114. * @param array array to be set.
  39115. * @returns this effect.
  39116. */
  39117. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39118. /**
  39119. * 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)
  39120. * @param uniformName Name of the variable.
  39121. * @param array array to be set.
  39122. * @returns this effect.
  39123. */
  39124. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39125. /**
  39126. * 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)
  39127. * @param uniformName Name of the variable.
  39128. * @param array array to be set.
  39129. * @returns this effect.
  39130. */
  39131. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39132. /**
  39133. * Sets an float array on a uniform variable.
  39134. * @param uniformName Name of the variable.
  39135. * @param array array to be set.
  39136. * @returns this effect.
  39137. */
  39138. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39139. /**
  39140. * 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)
  39141. * @param uniformName Name of the variable.
  39142. * @param array array to be set.
  39143. * @returns this effect.
  39144. */
  39145. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39146. /**
  39147. * 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)
  39148. * @param uniformName Name of the variable.
  39149. * @param array array to be set.
  39150. * @returns this effect.
  39151. */
  39152. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39153. /**
  39154. * 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)
  39155. * @param uniformName Name of the variable.
  39156. * @param array array to be set.
  39157. * @returns this effect.
  39158. */
  39159. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39160. /**
  39161. * Sets an array on a uniform variable.
  39162. * @param uniformName Name of the variable.
  39163. * @param array array to be set.
  39164. * @returns this effect.
  39165. */
  39166. setArray(uniformName: string, array: number[]): Effect;
  39167. /**
  39168. * 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)
  39169. * @param uniformName Name of the variable.
  39170. * @param array array to be set.
  39171. * @returns this effect.
  39172. */
  39173. setArray2(uniformName: string, array: number[]): Effect;
  39174. /**
  39175. * 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)
  39176. * @param uniformName Name of the variable.
  39177. * @param array array to be set.
  39178. * @returns this effect.
  39179. */
  39180. setArray3(uniformName: string, array: number[]): Effect;
  39181. /**
  39182. * 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)
  39183. * @param uniformName Name of the variable.
  39184. * @param array array to be set.
  39185. * @returns this effect.
  39186. */
  39187. setArray4(uniformName: string, array: number[]): Effect;
  39188. /**
  39189. * Sets matrices on a uniform variable.
  39190. * @param uniformName Name of the variable.
  39191. * @param matrices matrices to be set.
  39192. * @returns this effect.
  39193. */
  39194. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39195. /**
  39196. * Sets matrix on a uniform variable.
  39197. * @param uniformName Name of the variable.
  39198. * @param matrix matrix to be set.
  39199. * @returns this effect.
  39200. */
  39201. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39202. /**
  39203. * 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)
  39204. * @param uniformName Name of the variable.
  39205. * @param matrix matrix to be set.
  39206. * @returns this effect.
  39207. */
  39208. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39209. /**
  39210. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39211. * @param uniformName Name of the variable.
  39212. * @param matrix matrix to be set.
  39213. * @returns this effect.
  39214. */
  39215. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39216. /**
  39217. * Sets a float on a uniform variable.
  39218. * @param uniformName Name of the variable.
  39219. * @param value value to be set.
  39220. * @returns this effect.
  39221. */
  39222. setFloat(uniformName: string, value: number): Effect;
  39223. /**
  39224. * Sets a boolean on a uniform variable.
  39225. * @param uniformName Name of the variable.
  39226. * @param bool value to be set.
  39227. * @returns this effect.
  39228. */
  39229. setBool(uniformName: string, bool: boolean): Effect;
  39230. /**
  39231. * Sets a Vector2 on a uniform variable.
  39232. * @param uniformName Name of the variable.
  39233. * @param vector2 vector2 to be set.
  39234. * @returns this effect.
  39235. */
  39236. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39237. /**
  39238. * Sets a float2 on a uniform variable.
  39239. * @param uniformName Name of the variable.
  39240. * @param x First float in float2.
  39241. * @param y Second float in float2.
  39242. * @returns this effect.
  39243. */
  39244. setFloat2(uniformName: string, x: number, y: number): Effect;
  39245. /**
  39246. * Sets a Vector3 on a uniform variable.
  39247. * @param uniformName Name of the variable.
  39248. * @param vector3 Value to be set.
  39249. * @returns this effect.
  39250. */
  39251. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39252. /**
  39253. * Sets a float3 on a uniform variable.
  39254. * @param uniformName Name of the variable.
  39255. * @param x First float in float3.
  39256. * @param y Second float in float3.
  39257. * @param z Third float in float3.
  39258. * @returns this effect.
  39259. */
  39260. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39261. /**
  39262. * Sets a Vector4 on a uniform variable.
  39263. * @param uniformName Name of the variable.
  39264. * @param vector4 Value to be set.
  39265. * @returns this effect.
  39266. */
  39267. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39268. /**
  39269. * Sets a float4 on a uniform variable.
  39270. * @param uniformName Name of the variable.
  39271. * @param x First float in float4.
  39272. * @param y Second float in float4.
  39273. * @param z Third float in float4.
  39274. * @param w Fourth float in float4.
  39275. * @returns this effect.
  39276. */
  39277. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39278. /**
  39279. * Sets a Color3 on a uniform variable.
  39280. * @param uniformName Name of the variable.
  39281. * @param color3 Value to be set.
  39282. * @returns this effect.
  39283. */
  39284. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39285. /**
  39286. * Sets a Color4 on a uniform variable.
  39287. * @param uniformName Name of the variable.
  39288. * @param color3 Value to be set.
  39289. * @param alpha Alpha value to be set.
  39290. * @returns this effect.
  39291. */
  39292. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39293. /**
  39294. * Sets a Color4 on a uniform variable
  39295. * @param uniformName defines the name of the variable
  39296. * @param color4 defines the value to be set
  39297. * @returns this effect.
  39298. */
  39299. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39300. /**
  39301. * Release all associated resources.
  39302. **/
  39303. dispose(): void;
  39304. /**
  39305. * This function will add a new shader to the shader store
  39306. * @param name the name of the shader
  39307. * @param pixelShader optional pixel shader content
  39308. * @param vertexShader optional vertex shader content
  39309. */
  39310. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39311. /**
  39312. * Store of each shader (The can be looked up using effect.key)
  39313. */
  39314. static ShadersStore: {
  39315. [key: string]: string;
  39316. };
  39317. /**
  39318. * Store of each included file for a shader (The can be looked up using effect.key)
  39319. */
  39320. static IncludesShadersStore: {
  39321. [key: string]: string;
  39322. };
  39323. /**
  39324. * Resets the cache of effects.
  39325. */
  39326. static ResetCache(): void;
  39327. }
  39328. }
  39329. declare module BABYLON {
  39330. /**
  39331. * Interface used to describe the capabilities of the engine relatively to the current browser
  39332. */
  39333. export interface EngineCapabilities {
  39334. /** Maximum textures units per fragment shader */
  39335. maxTexturesImageUnits: number;
  39336. /** Maximum texture units per vertex shader */
  39337. maxVertexTextureImageUnits: number;
  39338. /** Maximum textures units in the entire pipeline */
  39339. maxCombinedTexturesImageUnits: number;
  39340. /** Maximum texture size */
  39341. maxTextureSize: number;
  39342. /** Maximum texture samples */
  39343. maxSamples?: number;
  39344. /** Maximum cube texture size */
  39345. maxCubemapTextureSize: number;
  39346. /** Maximum render texture size */
  39347. maxRenderTextureSize: number;
  39348. /** Maximum number of vertex attributes */
  39349. maxVertexAttribs: number;
  39350. /** Maximum number of varyings */
  39351. maxVaryingVectors: number;
  39352. /** Maximum number of uniforms per vertex shader */
  39353. maxVertexUniformVectors: number;
  39354. /** Maximum number of uniforms per fragment shader */
  39355. maxFragmentUniformVectors: number;
  39356. /** Defines if standard derivates (dx/dy) are supported */
  39357. standardDerivatives: boolean;
  39358. /** Defines if s3tc texture compression is supported */
  39359. s3tc?: WEBGL_compressed_texture_s3tc;
  39360. /** Defines if pvrtc texture compression is supported */
  39361. pvrtc: any;
  39362. /** Defines if etc1 texture compression is supported */
  39363. etc1: any;
  39364. /** Defines if etc2 texture compression is supported */
  39365. etc2: any;
  39366. /** Defines if astc texture compression is supported */
  39367. astc: any;
  39368. /** Defines if bptc texture compression is supported */
  39369. bptc: any;
  39370. /** Defines if float textures are supported */
  39371. textureFloat: boolean;
  39372. /** Defines if vertex array objects are supported */
  39373. vertexArrayObject: boolean;
  39374. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39375. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39376. /** Gets the maximum level of anisotropy supported */
  39377. maxAnisotropy: number;
  39378. /** Defines if instancing is supported */
  39379. instancedArrays: boolean;
  39380. /** Defines if 32 bits indices are supported */
  39381. uintIndices: boolean;
  39382. /** Defines if high precision shaders are supported */
  39383. highPrecisionShaderSupported: boolean;
  39384. /** Defines if depth reading in the fragment shader is supported */
  39385. fragmentDepthSupported: boolean;
  39386. /** Defines if float texture linear filtering is supported*/
  39387. textureFloatLinearFiltering: boolean;
  39388. /** Defines if rendering to float textures is supported */
  39389. textureFloatRender: boolean;
  39390. /** Defines if half float textures are supported*/
  39391. textureHalfFloat: boolean;
  39392. /** Defines if half float texture linear filtering is supported*/
  39393. textureHalfFloatLinearFiltering: boolean;
  39394. /** Defines if rendering to half float textures is supported */
  39395. textureHalfFloatRender: boolean;
  39396. /** Defines if textureLOD shader command is supported */
  39397. textureLOD: boolean;
  39398. /** Defines if draw buffers extension is supported */
  39399. drawBuffersExtension: boolean;
  39400. /** Defines if depth textures are supported */
  39401. depthTextureExtension: boolean;
  39402. /** Defines if float color buffer are supported */
  39403. colorBufferFloat: boolean;
  39404. /** Gets disjoint timer query extension (null if not supported) */
  39405. timerQuery?: EXT_disjoint_timer_query;
  39406. /** Defines if timestamp can be used with timer query */
  39407. canUseTimestampForTimerQuery: boolean;
  39408. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39409. multiview?: any;
  39410. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39411. oculusMultiview?: any;
  39412. /** Function used to let the system compiles shaders in background */
  39413. parallelShaderCompile?: {
  39414. COMPLETION_STATUS_KHR: number;
  39415. };
  39416. /** Max number of texture samples for MSAA */
  39417. maxMSAASamples: number;
  39418. /** Defines if the blend min max extension is supported */
  39419. blendMinMax: boolean;
  39420. /** 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 */
  39421. canUseGLInstanceID: boolean;
  39422. }
  39423. }
  39424. declare module BABYLON {
  39425. /**
  39426. * @hidden
  39427. **/
  39428. export class DepthCullingState {
  39429. private _isDepthTestDirty;
  39430. private _isDepthMaskDirty;
  39431. private _isDepthFuncDirty;
  39432. private _isCullFaceDirty;
  39433. private _isCullDirty;
  39434. private _isZOffsetDirty;
  39435. private _isFrontFaceDirty;
  39436. private _depthTest;
  39437. private _depthMask;
  39438. private _depthFunc;
  39439. private _cull;
  39440. private _cullFace;
  39441. private _zOffset;
  39442. private _frontFace;
  39443. /**
  39444. * Initializes the state.
  39445. */
  39446. constructor();
  39447. get isDirty(): boolean;
  39448. get zOffset(): number;
  39449. set zOffset(value: number);
  39450. get cullFace(): Nullable<number>;
  39451. set cullFace(value: Nullable<number>);
  39452. get cull(): Nullable<boolean>;
  39453. set cull(value: Nullable<boolean>);
  39454. get depthFunc(): Nullable<number>;
  39455. set depthFunc(value: Nullable<number>);
  39456. get depthMask(): boolean;
  39457. set depthMask(value: boolean);
  39458. get depthTest(): boolean;
  39459. set depthTest(value: boolean);
  39460. get frontFace(): Nullable<number>;
  39461. set frontFace(value: Nullable<number>);
  39462. reset(): void;
  39463. apply(gl: WebGLRenderingContext): void;
  39464. }
  39465. }
  39466. declare module BABYLON {
  39467. /**
  39468. * @hidden
  39469. **/
  39470. export class StencilState {
  39471. /** 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 */
  39472. static readonly ALWAYS: number;
  39473. /** Passed to stencilOperation to specify that stencil value must be kept */
  39474. static readonly KEEP: number;
  39475. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39476. static readonly REPLACE: number;
  39477. private _isStencilTestDirty;
  39478. private _isStencilMaskDirty;
  39479. private _isStencilFuncDirty;
  39480. private _isStencilOpDirty;
  39481. private _stencilTest;
  39482. private _stencilMask;
  39483. private _stencilFunc;
  39484. private _stencilFuncRef;
  39485. private _stencilFuncMask;
  39486. private _stencilOpStencilFail;
  39487. private _stencilOpDepthFail;
  39488. private _stencilOpStencilDepthPass;
  39489. get isDirty(): boolean;
  39490. get stencilFunc(): number;
  39491. set stencilFunc(value: number);
  39492. get stencilFuncRef(): number;
  39493. set stencilFuncRef(value: number);
  39494. get stencilFuncMask(): number;
  39495. set stencilFuncMask(value: number);
  39496. get stencilOpStencilFail(): number;
  39497. set stencilOpStencilFail(value: number);
  39498. get stencilOpDepthFail(): number;
  39499. set stencilOpDepthFail(value: number);
  39500. get stencilOpStencilDepthPass(): number;
  39501. set stencilOpStencilDepthPass(value: number);
  39502. get stencilMask(): number;
  39503. set stencilMask(value: number);
  39504. get stencilTest(): boolean;
  39505. set stencilTest(value: boolean);
  39506. constructor();
  39507. reset(): void;
  39508. apply(gl: WebGLRenderingContext): void;
  39509. }
  39510. }
  39511. declare module BABYLON {
  39512. /**
  39513. * @hidden
  39514. **/
  39515. export class AlphaState {
  39516. _blendFunctionParameters: Nullable<number>[];
  39517. _blendEquationParameters: Nullable<number>[];
  39518. _blendConstants: Nullable<number>[];
  39519. _isBlendConstantsDirty: boolean;
  39520. private _alphaBlend;
  39521. private _isAlphaBlendDirty;
  39522. private _isBlendFunctionParametersDirty;
  39523. private _isBlendEquationParametersDirty;
  39524. /**
  39525. * Initializes the state.
  39526. */
  39527. constructor();
  39528. get isDirty(): boolean;
  39529. get alphaBlend(): boolean;
  39530. set alphaBlend(value: boolean);
  39531. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39532. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39533. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39534. reset(): void;
  39535. apply(gl: WebGLRenderingContext): void;
  39536. }
  39537. }
  39538. declare module BABYLON {
  39539. /** @hidden */
  39540. export class WebGLShaderProcessor implements IShaderProcessor {
  39541. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39542. }
  39543. }
  39544. declare module BABYLON {
  39545. /** @hidden */
  39546. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39547. attributeProcessor(attribute: string): string;
  39548. varyingProcessor(varying: string, isFragment: boolean): string;
  39549. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39550. }
  39551. }
  39552. declare module BABYLON {
  39553. /**
  39554. * Interface for attribute information associated with buffer instanciation
  39555. */
  39556. export interface InstancingAttributeInfo {
  39557. /**
  39558. * Name of the GLSL attribute
  39559. * if attribute index is not specified, this is used to retrieve the index from the effect
  39560. */
  39561. attributeName: string;
  39562. /**
  39563. * Index/offset of the attribute in the vertex shader
  39564. * if not specified, this will be computes from the name.
  39565. */
  39566. index?: number;
  39567. /**
  39568. * size of the attribute, 1, 2, 3 or 4
  39569. */
  39570. attributeSize: number;
  39571. /**
  39572. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39573. */
  39574. offset: number;
  39575. /**
  39576. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39577. * default to 1
  39578. */
  39579. divisor?: number;
  39580. /**
  39581. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39582. * default is FLOAT
  39583. */
  39584. attributeType?: number;
  39585. /**
  39586. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39587. */
  39588. normalized?: boolean;
  39589. }
  39590. }
  39591. declare module BABYLON {
  39592. /** @hidden */
  39593. export interface EngineFeatures {
  39594. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  39595. forceBitmapOverHTMLImageElement: boolean;
  39596. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  39597. supportRenderAndCopyToLodForFloatTextures: boolean;
  39598. /** Indicates that the engine support handling depth/stencil textures */
  39599. supportDepthStencilTexture: boolean;
  39600. /** Indicates that the engine support shadow samplers */
  39601. supportShadowSamplers: boolean;
  39602. /** 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 */
  39603. uniformBufferHardCheckMatrix: boolean;
  39604. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  39605. allowTexturePrefiltering: boolean;
  39606. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  39607. trackUbosInFrame: boolean;
  39608. /** Indicates that the Cascaded Shadow Map technic is supported */
  39609. supportCSM: boolean;
  39610. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  39611. basisNeedsPOT: boolean;
  39612. /** Indicates that the engine supports 3D textures */
  39613. support3DTextures: boolean;
  39614. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  39615. needTypeSuffixInShaderConstants: boolean;
  39616. /** Indicates that MSAA is supported */
  39617. supportMSAA: boolean;
  39618. /** Indicates that SSAO2 is supported */
  39619. supportSSAO2: boolean;
  39620. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  39621. supportExtendedTextureFormats: boolean;
  39622. /** Indicates that the switch/case construct is supported in shaders */
  39623. supportSwitchCaseInShader: boolean;
  39624. /** @hidden */
  39625. _collectUbosUpdatedInFrame: boolean;
  39626. }
  39627. }
  39628. declare module BABYLON {
  39629. /** @hidden */
  39630. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  39631. private _webGLTexture;
  39632. private _context;
  39633. get underlyingResource(): Nullable<WebGLTexture>;
  39634. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  39635. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  39636. set(hardwareTexture: WebGLTexture): void;
  39637. reset(): void;
  39638. release(): void;
  39639. }
  39640. }
  39641. declare module BABYLON {
  39642. interface ThinEngine {
  39643. /**
  39644. * Update a video texture
  39645. * @param texture defines the texture to update
  39646. * @param video defines the video element to use
  39647. * @param invertY defines if data must be stored with Y axis inverted
  39648. */
  39649. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39650. }
  39651. }
  39652. declare module BABYLON {
  39653. interface ThinEngine {
  39654. /**
  39655. * Creates a dynamic texture
  39656. * @param width defines the width of the texture
  39657. * @param height defines the height of the texture
  39658. * @param generateMipMaps defines if the engine should generate the mip levels
  39659. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39660. * @returns the dynamic texture inside an InternalTexture
  39661. */
  39662. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39663. /**
  39664. * Update the content of a dynamic texture
  39665. * @param texture defines the texture to update
  39666. * @param source defines the source containing the data
  39667. * @param invertY defines if data must be stored with Y axis inverted
  39668. * @param premulAlpha defines if alpha is stored as premultiplied
  39669. * @param format defines the format of the data
  39670. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39671. */
  39672. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39673. }
  39674. }
  39675. declare module BABYLON {
  39676. /**
  39677. * Settings for finer control over video usage
  39678. */
  39679. export interface VideoTextureSettings {
  39680. /**
  39681. * Applies `autoplay` to video, if specified
  39682. */
  39683. autoPlay?: boolean;
  39684. /**
  39685. * Applies `muted` to video, if specified
  39686. */
  39687. muted?: boolean;
  39688. /**
  39689. * Applies `loop` to video, if specified
  39690. */
  39691. loop?: boolean;
  39692. /**
  39693. * Automatically updates internal texture from video at every frame in the render loop
  39694. */
  39695. autoUpdateTexture: boolean;
  39696. /**
  39697. * Image src displayed during the video loading or until the user interacts with the video.
  39698. */
  39699. poster?: string;
  39700. }
  39701. /**
  39702. * If you want to display a video in your scene, this is the special texture for that.
  39703. * This special texture works similar to other textures, with the exception of a few parameters.
  39704. * @see https://doc.babylonjs.com/how_to/video_texture
  39705. */
  39706. export class VideoTexture extends Texture {
  39707. /**
  39708. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39709. */
  39710. readonly autoUpdateTexture: boolean;
  39711. /**
  39712. * The video instance used by the texture internally
  39713. */
  39714. readonly video: HTMLVideoElement;
  39715. private _onUserActionRequestedObservable;
  39716. /**
  39717. * Event triggerd when a dom action is required by the user to play the video.
  39718. * This happens due to recent changes in browser policies preventing video to auto start.
  39719. */
  39720. get onUserActionRequestedObservable(): Observable<Texture>;
  39721. private _generateMipMaps;
  39722. private _stillImageCaptured;
  39723. private _displayingPosterTexture;
  39724. private _settings;
  39725. private _createInternalTextureOnEvent;
  39726. private _frameId;
  39727. private _currentSrc;
  39728. /**
  39729. * Creates a video texture.
  39730. * If you want to display a video in your scene, this is the special texture for that.
  39731. * This special texture works similar to other textures, with the exception of a few parameters.
  39732. * @see https://doc.babylonjs.com/how_to/video_texture
  39733. * @param name optional name, will detect from video source, if not defined
  39734. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39735. * @param scene is obviously the current scene.
  39736. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39737. * @param invertY is false by default but can be used to invert video on Y axis
  39738. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39739. * @param settings allows finer control over video usage
  39740. */
  39741. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39742. private _getName;
  39743. private _getVideo;
  39744. private _createInternalTexture;
  39745. private reset;
  39746. /**
  39747. * @hidden Internal method to initiate `update`.
  39748. */
  39749. _rebuild(): void;
  39750. /**
  39751. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39752. */
  39753. update(): void;
  39754. /**
  39755. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39756. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39757. */
  39758. updateTexture(isVisible: boolean): void;
  39759. protected _updateInternalTexture: () => void;
  39760. /**
  39761. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39762. * @param url New url.
  39763. */
  39764. updateURL(url: string): void;
  39765. /**
  39766. * Clones the texture.
  39767. * @returns the cloned texture
  39768. */
  39769. clone(): VideoTexture;
  39770. /**
  39771. * Dispose the texture and release its associated resources.
  39772. */
  39773. dispose(): void;
  39774. /**
  39775. * Creates a video texture straight from a stream.
  39776. * @param scene Define the scene the texture should be created in
  39777. * @param stream Define the stream the texture should be created from
  39778. * @returns The created video texture as a promise
  39779. */
  39780. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39781. /**
  39782. * Creates a video texture straight from your WebCam video feed.
  39783. * @param scene Define the scene the texture should be created in
  39784. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39785. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39786. * @returns The created video texture as a promise
  39787. */
  39788. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39789. minWidth: number;
  39790. maxWidth: number;
  39791. minHeight: number;
  39792. maxHeight: number;
  39793. deviceId: string;
  39794. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39795. /**
  39796. * Creates a video texture straight from your WebCam video feed.
  39797. * @param scene Define the scene the texture should be created in
  39798. * @param onReady Define a callback to triggered once the texture will be ready
  39799. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39800. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39801. */
  39802. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39803. minWidth: number;
  39804. maxWidth: number;
  39805. minHeight: number;
  39806. maxHeight: number;
  39807. deviceId: string;
  39808. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39809. }
  39810. }
  39811. declare module BABYLON {
  39812. /**
  39813. * Defines the interface used by objects working like Scene
  39814. * @hidden
  39815. */
  39816. export interface ISceneLike {
  39817. _addPendingData(data: any): void;
  39818. _removePendingData(data: any): void;
  39819. offlineProvider: IOfflineProvider;
  39820. }
  39821. /**
  39822. * Information about the current host
  39823. */
  39824. export interface HostInformation {
  39825. /**
  39826. * Defines if the current host is a mobile
  39827. */
  39828. isMobile: boolean;
  39829. }
  39830. /** Interface defining initialization parameters for Engine class */
  39831. export interface EngineOptions extends WebGLContextAttributes {
  39832. /**
  39833. * Defines if the engine should no exceed a specified device ratio
  39834. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39835. */
  39836. limitDeviceRatio?: number;
  39837. /**
  39838. * Defines if webvr should be enabled automatically
  39839. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39840. */
  39841. autoEnableWebVR?: boolean;
  39842. /**
  39843. * Defines if webgl2 should be turned off even if supported
  39844. * @see https://doc.babylonjs.com/features/webgl2
  39845. */
  39846. disableWebGL2Support?: boolean;
  39847. /**
  39848. * Defines if webaudio should be initialized as well
  39849. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39850. */
  39851. audioEngine?: boolean;
  39852. /**
  39853. * Defines if animations should run using a deterministic lock step
  39854. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39855. */
  39856. deterministicLockstep?: boolean;
  39857. /** Defines the maximum steps to use with deterministic lock step mode */
  39858. lockstepMaxSteps?: number;
  39859. /** Defines the seconds between each deterministic lock step */
  39860. timeStep?: number;
  39861. /**
  39862. * Defines that engine should ignore context lost events
  39863. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39864. */
  39865. doNotHandleContextLost?: boolean;
  39866. /**
  39867. * Defines that engine should ignore modifying touch action attribute and style
  39868. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39869. */
  39870. doNotHandleTouchAction?: boolean;
  39871. /**
  39872. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39873. */
  39874. useHighPrecisionFloats?: boolean;
  39875. /**
  39876. * Make the canvas XR Compatible for XR sessions
  39877. */
  39878. xrCompatible?: boolean;
  39879. /**
  39880. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39881. */
  39882. useHighPrecisionMatrix?: boolean;
  39883. /**
  39884. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39885. */
  39886. failIfMajorPerformanceCaveat?: boolean;
  39887. /**
  39888. * Defines whether to adapt to the device's viewport characteristics (default: false)
  39889. */
  39890. adaptToDeviceRatio?: boolean;
  39891. }
  39892. /**
  39893. * The base engine class (root of all engines)
  39894. */
  39895. export class ThinEngine {
  39896. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39897. static ExceptionList: ({
  39898. key: string;
  39899. capture: string;
  39900. captureConstraint: number;
  39901. targets: string[];
  39902. } | {
  39903. key: string;
  39904. capture: null;
  39905. captureConstraint: null;
  39906. targets: string[];
  39907. })[];
  39908. /** @hidden */
  39909. static _TextureLoaders: IInternalTextureLoader[];
  39910. /**
  39911. * Returns the current npm package of the sdk
  39912. */
  39913. static get NpmPackage(): string;
  39914. /**
  39915. * Returns the current version of the framework
  39916. */
  39917. static get Version(): string;
  39918. /**
  39919. * Returns a string describing the current engine
  39920. */
  39921. get description(): string;
  39922. /**
  39923. * Returns the name of the engine
  39924. */
  39925. get name(): string;
  39926. /**
  39927. * Returns the version of the engine
  39928. */
  39929. get version(): number;
  39930. /**
  39931. * Gets or sets the epsilon value used by collision engine
  39932. */
  39933. static CollisionsEpsilon: number;
  39934. /**
  39935. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39936. */
  39937. static get ShadersRepository(): string;
  39938. static set ShadersRepository(value: string);
  39939. /** @hidden */
  39940. _shaderProcessor: Nullable<IShaderProcessor>;
  39941. /**
  39942. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39943. */
  39944. forcePOTTextures: boolean;
  39945. /**
  39946. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39947. */
  39948. isFullscreen: boolean;
  39949. /**
  39950. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39951. */
  39952. cullBackFaces: boolean;
  39953. /**
  39954. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39955. */
  39956. renderEvenInBackground: boolean;
  39957. /**
  39958. * Gets or sets a boolean indicating that cache can be kept between frames
  39959. */
  39960. preventCacheWipeBetweenFrames: boolean;
  39961. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39962. validateShaderPrograms: boolean;
  39963. /**
  39964. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39965. * This can provide greater z depth for distant objects.
  39966. */
  39967. useReverseDepthBuffer: boolean;
  39968. /**
  39969. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39970. */
  39971. disableUniformBuffers: boolean;
  39972. private _frameId;
  39973. /**
  39974. * Gets the current frame id
  39975. */
  39976. get frameId(): number;
  39977. /** @hidden */
  39978. _uniformBuffers: UniformBuffer[];
  39979. /**
  39980. * Gets a boolean indicating that the engine supports uniform buffers
  39981. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39982. */
  39983. get supportsUniformBuffers(): boolean;
  39984. /** @hidden */
  39985. _gl: WebGLRenderingContext;
  39986. /** @hidden */
  39987. _webGLVersion: number;
  39988. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39989. protected _windowIsBackground: boolean;
  39990. protected _creationOptions: EngineOptions;
  39991. protected _highPrecisionShadersAllowed: boolean;
  39992. /** @hidden */
  39993. get _shouldUseHighPrecisionShader(): boolean;
  39994. /**
  39995. * Gets a boolean indicating that only power of 2 textures are supported
  39996. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39997. */
  39998. get needPOTTextures(): boolean;
  39999. /** @hidden */
  40000. _badOS: boolean;
  40001. /** @hidden */
  40002. _badDesktopOS: boolean;
  40003. protected _hardwareScalingLevel: number;
  40004. /** @hidden */
  40005. _caps: EngineCapabilities;
  40006. /** @hidden */
  40007. _features: EngineFeatures;
  40008. protected _isStencilEnable: boolean;
  40009. private _glVersion;
  40010. private _glRenderer;
  40011. private _glVendor;
  40012. /** @hidden */
  40013. _videoTextureSupported: boolean;
  40014. protected _renderingQueueLaunched: boolean;
  40015. protected _activeRenderLoops: (() => void)[];
  40016. /**
  40017. * Observable signaled when a context lost event is raised
  40018. */
  40019. onContextLostObservable: Observable<ThinEngine>;
  40020. /**
  40021. * Observable signaled when a context restored event is raised
  40022. */
  40023. onContextRestoredObservable: Observable<ThinEngine>;
  40024. private _onContextLost;
  40025. private _onContextRestored;
  40026. protected _contextWasLost: boolean;
  40027. /** @hidden */
  40028. _doNotHandleContextLost: boolean;
  40029. /**
  40030. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40031. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40032. */
  40033. get doNotHandleContextLost(): boolean;
  40034. set doNotHandleContextLost(value: boolean);
  40035. /**
  40036. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40037. */
  40038. disableVertexArrayObjects: boolean;
  40039. /** @hidden */
  40040. protected _colorWrite: boolean;
  40041. /** @hidden */
  40042. protected _colorWriteChanged: boolean;
  40043. /** @hidden */
  40044. protected _depthCullingState: DepthCullingState;
  40045. /** @hidden */
  40046. protected _stencilState: StencilState;
  40047. /** @hidden */
  40048. _alphaState: AlphaState;
  40049. /** @hidden */
  40050. _alphaMode: number;
  40051. /** @hidden */
  40052. _alphaEquation: number;
  40053. /** @hidden */
  40054. _internalTexturesCache: InternalTexture[];
  40055. /** @hidden */
  40056. protected _activeChannel: number;
  40057. private _currentTextureChannel;
  40058. /** @hidden */
  40059. protected _boundTexturesCache: {
  40060. [key: string]: Nullable<InternalTexture>;
  40061. };
  40062. /** @hidden */
  40063. protected _currentEffect: Nullable<Effect>;
  40064. /** @hidden */
  40065. protected _currentProgram: Nullable<WebGLProgram>;
  40066. protected _compiledEffects: {
  40067. [key: string]: Effect;
  40068. };
  40069. private _vertexAttribArraysEnabled;
  40070. /** @hidden */
  40071. protected _cachedViewport: Nullable<IViewportLike>;
  40072. private _cachedVertexArrayObject;
  40073. /** @hidden */
  40074. protected _cachedVertexBuffers: any;
  40075. /** @hidden */
  40076. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40077. /** @hidden */
  40078. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40079. /** @hidden */
  40080. _currentRenderTarget: Nullable<InternalTexture>;
  40081. private _uintIndicesCurrentlySet;
  40082. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40083. /** @hidden */
  40084. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40085. /** @hidden */
  40086. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40087. private _currentBufferPointers;
  40088. private _currentInstanceLocations;
  40089. private _currentInstanceBuffers;
  40090. private _textureUnits;
  40091. /** @hidden */
  40092. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40093. /** @hidden */
  40094. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40095. /** @hidden */
  40096. _boundRenderFunction: any;
  40097. private _vaoRecordInProgress;
  40098. private _mustWipeVertexAttributes;
  40099. private _emptyTexture;
  40100. private _emptyCubeTexture;
  40101. private _emptyTexture3D;
  40102. private _emptyTexture2DArray;
  40103. /** @hidden */
  40104. _frameHandler: number;
  40105. private _nextFreeTextureSlots;
  40106. private _maxSimultaneousTextures;
  40107. private _activeRequests;
  40108. /** @hidden */
  40109. _transformTextureUrl: Nullable<(url: string) => string>;
  40110. /**
  40111. * Gets information about the current host
  40112. */
  40113. hostInformation: HostInformation;
  40114. protected get _supportsHardwareTextureRescaling(): boolean;
  40115. private _framebufferDimensionsObject;
  40116. /**
  40117. * sets the object from which width and height will be taken from when getting render width and height
  40118. * Will fallback to the gl object
  40119. * @param dimensions the framebuffer width and height that will be used.
  40120. */
  40121. set framebufferDimensionsObject(dimensions: Nullable<{
  40122. framebufferWidth: number;
  40123. framebufferHeight: number;
  40124. }>);
  40125. /**
  40126. * Gets the current viewport
  40127. */
  40128. get currentViewport(): Nullable<IViewportLike>;
  40129. /**
  40130. * Gets the default empty texture
  40131. */
  40132. get emptyTexture(): InternalTexture;
  40133. /**
  40134. * Gets the default empty 3D texture
  40135. */
  40136. get emptyTexture3D(): InternalTexture;
  40137. /**
  40138. * Gets the default empty 2D array texture
  40139. */
  40140. get emptyTexture2DArray(): InternalTexture;
  40141. /**
  40142. * Gets the default empty cube texture
  40143. */
  40144. get emptyCubeTexture(): InternalTexture;
  40145. /**
  40146. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40147. */
  40148. premultipliedAlpha: boolean;
  40149. /**
  40150. * Observable event triggered before each texture is initialized
  40151. */
  40152. onBeforeTextureInitObservable: Observable<Texture>;
  40153. /** @hidden */
  40154. protected _isWebGPU: boolean;
  40155. /**
  40156. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40157. */
  40158. get isWebGPU(): boolean;
  40159. /** @hidden */
  40160. protected _shaderPlatformName: string;
  40161. /**
  40162. * Gets the shader platfrom name used by the effects.
  40163. */
  40164. get shaderPlatformName(): string;
  40165. /**
  40166. * Creates a new engine
  40167. * @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
  40168. * @param antialias defines enable antialiasing (default: false)
  40169. * @param options defines further options to be sent to the getContext() function
  40170. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40171. */
  40172. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40173. /**
  40174. * @hidden
  40175. */
  40176. _debugPushGroup(groupName: string, targetObject?: number): void;
  40177. /**
  40178. * @hidden
  40179. */
  40180. _debugPopGroup(targetObject?: number): void;
  40181. /**
  40182. * @hidden
  40183. */
  40184. _debugInsertMarker(text: string, targetObject?: number): void;
  40185. /**
  40186. * Shared initialization across engines types.
  40187. * @param canvas The canvas associated with this instance of the engine.
  40188. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40189. * @param audioEngine Defines if an audio engine should be created by default
  40190. */
  40191. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40192. /**
  40193. * Gets a shader processor implementation fitting with the current engine type.
  40194. * @returns The shader processor implementation.
  40195. */
  40196. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40197. /** @hidden */
  40198. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40199. private _rebuildInternalTextures;
  40200. private _rebuildEffects;
  40201. /**
  40202. * Gets a boolean indicating if all created effects are ready
  40203. * @returns true if all effects are ready
  40204. */
  40205. areAllEffectsReady(): boolean;
  40206. protected _rebuildBuffers(): void;
  40207. protected _initGLContext(): void;
  40208. protected _initFeatures(): void;
  40209. /**
  40210. * Gets version of the current webGL context
  40211. * Keep it for back compat - use version instead
  40212. */
  40213. get webGLVersion(): number;
  40214. /**
  40215. * Gets a string identifying the name of the class
  40216. * @returns "Engine" string
  40217. */
  40218. getClassName(): string;
  40219. /**
  40220. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40221. */
  40222. get isStencilEnable(): boolean;
  40223. /** @hidden */
  40224. _prepareWorkingCanvas(): void;
  40225. /**
  40226. * Reset the texture cache to empty state
  40227. */
  40228. resetTextureCache(): void;
  40229. /**
  40230. * Gets an object containing information about the current webGL context
  40231. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40232. */
  40233. getGlInfo(): {
  40234. vendor: string;
  40235. renderer: string;
  40236. version: string;
  40237. };
  40238. /**
  40239. * Defines the hardware scaling level.
  40240. * By default the hardware scaling level is computed from the window device ratio.
  40241. * 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.
  40242. * @param level defines the level to use
  40243. */
  40244. setHardwareScalingLevel(level: number): void;
  40245. /**
  40246. * Gets the current hardware scaling level.
  40247. * By default the hardware scaling level is computed from the window device ratio.
  40248. * 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.
  40249. * @returns a number indicating the current hardware scaling level
  40250. */
  40251. getHardwareScalingLevel(): number;
  40252. /**
  40253. * Gets the list of loaded textures
  40254. * @returns an array containing all loaded textures
  40255. */
  40256. getLoadedTexturesCache(): InternalTexture[];
  40257. /**
  40258. * Gets the object containing all engine capabilities
  40259. * @returns the EngineCapabilities object
  40260. */
  40261. getCaps(): EngineCapabilities;
  40262. /**
  40263. * stop executing a render loop function and remove it from the execution array
  40264. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40265. */
  40266. stopRenderLoop(renderFunction?: () => void): void;
  40267. /** @hidden */
  40268. _renderLoop(): void;
  40269. /**
  40270. * Gets the HTML canvas attached with the current webGL context
  40271. * @returns a HTML canvas
  40272. */
  40273. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40274. /**
  40275. * Gets host window
  40276. * @returns the host window object
  40277. */
  40278. getHostWindow(): Nullable<Window>;
  40279. /**
  40280. * Gets the current render width
  40281. * @param useScreen defines if screen size must be used (or the current render target if any)
  40282. * @returns a number defining the current render width
  40283. */
  40284. getRenderWidth(useScreen?: boolean): number;
  40285. /**
  40286. * Gets the current render height
  40287. * @param useScreen defines if screen size must be used (or the current render target if any)
  40288. * @returns a number defining the current render height
  40289. */
  40290. getRenderHeight(useScreen?: boolean): number;
  40291. /**
  40292. * Can be used to override the current requestAnimationFrame requester.
  40293. * @hidden
  40294. */
  40295. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40296. /**
  40297. * Register and execute a render loop. The engine can have more than one render function
  40298. * @param renderFunction defines the function to continuously execute
  40299. */
  40300. runRenderLoop(renderFunction: () => void): void;
  40301. /**
  40302. * Clear the current render buffer or the current render target (if any is set up)
  40303. * @param color defines the color to use
  40304. * @param backBuffer defines if the back buffer must be cleared
  40305. * @param depth defines if the depth buffer must be cleared
  40306. * @param stencil defines if the stencil buffer must be cleared
  40307. */
  40308. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40309. protected _viewportCached: {
  40310. x: number;
  40311. y: number;
  40312. z: number;
  40313. w: number;
  40314. };
  40315. /** @hidden */
  40316. _viewport(x: number, y: number, width: number, height: number): void;
  40317. /**
  40318. * Set the WebGL's viewport
  40319. * @param viewport defines the viewport element to be used
  40320. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40321. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40322. */
  40323. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40324. /**
  40325. * Begin a new frame
  40326. */
  40327. beginFrame(): void;
  40328. /**
  40329. * Enf the current frame
  40330. */
  40331. endFrame(): void;
  40332. /**
  40333. * Resize the view according to the canvas' size
  40334. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40335. */
  40336. resize(forceSetSize?: boolean): void;
  40337. /**
  40338. * Force a specific size of the canvas
  40339. * @param width defines the new canvas' width
  40340. * @param height defines the new canvas' height
  40341. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40342. * @returns true if the size was changed
  40343. */
  40344. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40345. /**
  40346. * Binds the frame buffer to the specified texture.
  40347. * @param texture The texture to render to or null for the default canvas
  40348. * @param faceIndex The face of the texture to render to in case of cube texture
  40349. * @param requiredWidth The width of the target to render to
  40350. * @param requiredHeight The height of the target to render to
  40351. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40352. * @param lodLevel defines the lod level to bind to the frame buffer
  40353. * @param layer defines the 2d array index to bind to frame buffer to
  40354. */
  40355. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40356. /** @hidden */
  40357. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40358. /**
  40359. * Unbind the current render target texture from the webGL context
  40360. * @param texture defines the render target texture to unbind
  40361. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40362. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40363. */
  40364. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40365. /**
  40366. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40367. */
  40368. flushFramebuffer(): void;
  40369. /**
  40370. * Unbind the current render target and bind the default framebuffer
  40371. */
  40372. restoreDefaultFramebuffer(): void;
  40373. /** @hidden */
  40374. protected _resetVertexBufferBinding(): void;
  40375. /**
  40376. * Creates a vertex buffer
  40377. * @param data the data for the vertex buffer
  40378. * @returns the new WebGL static buffer
  40379. */
  40380. createVertexBuffer(data: DataArray): DataBuffer;
  40381. private _createVertexBuffer;
  40382. /**
  40383. * Creates a dynamic vertex buffer
  40384. * @param data the data for the dynamic vertex buffer
  40385. * @returns the new WebGL dynamic buffer
  40386. */
  40387. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40388. protected _resetIndexBufferBinding(): void;
  40389. /**
  40390. * Creates a new index buffer
  40391. * @param indices defines the content of the index buffer
  40392. * @param updatable defines if the index buffer must be updatable
  40393. * @returns a new webGL buffer
  40394. */
  40395. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40396. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40397. /**
  40398. * Bind a webGL buffer to the webGL context
  40399. * @param buffer defines the buffer to bind
  40400. */
  40401. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40402. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40403. private bindBuffer;
  40404. /**
  40405. * update the bound buffer with the given data
  40406. * @param data defines the data to update
  40407. */
  40408. updateArrayBuffer(data: Float32Array): void;
  40409. private _vertexAttribPointer;
  40410. /** @hidden */
  40411. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40412. private _bindVertexBuffersAttributes;
  40413. /**
  40414. * Records a vertex array object
  40415. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40416. * @param vertexBuffers defines the list of vertex buffers to store
  40417. * @param indexBuffer defines the index buffer to store
  40418. * @param effect defines the effect to store
  40419. * @returns the new vertex array object
  40420. */
  40421. recordVertexArrayObject(vertexBuffers: {
  40422. [key: string]: VertexBuffer;
  40423. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40424. /**
  40425. * Bind a specific vertex array object
  40426. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40427. * @param vertexArrayObject defines the vertex array object to bind
  40428. * @param indexBuffer defines the index buffer to bind
  40429. */
  40430. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40431. /**
  40432. * Bind webGl buffers directly to the webGL context
  40433. * @param vertexBuffer defines the vertex buffer to bind
  40434. * @param indexBuffer defines the index buffer to bind
  40435. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40436. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40437. * @param effect defines the effect associated with the vertex buffer
  40438. */
  40439. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40440. private _unbindVertexArrayObject;
  40441. /**
  40442. * Bind a list of vertex buffers to the webGL context
  40443. * @param vertexBuffers defines the list of vertex buffers to bind
  40444. * @param indexBuffer defines the index buffer to bind
  40445. * @param effect defines the effect associated with the vertex buffers
  40446. */
  40447. bindBuffers(vertexBuffers: {
  40448. [key: string]: Nullable<VertexBuffer>;
  40449. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40450. /**
  40451. * Unbind all instance attributes
  40452. */
  40453. unbindInstanceAttributes(): void;
  40454. /**
  40455. * Release and free the memory of a vertex array object
  40456. * @param vao defines the vertex array object to delete
  40457. */
  40458. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40459. /** @hidden */
  40460. _releaseBuffer(buffer: DataBuffer): boolean;
  40461. protected _deleteBuffer(buffer: DataBuffer): void;
  40462. /**
  40463. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40464. * @param instancesBuffer defines the webGL buffer to update and bind
  40465. * @param data defines the data to store in the buffer
  40466. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40467. */
  40468. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40469. /**
  40470. * Bind the content of a webGL buffer used with instantiation
  40471. * @param instancesBuffer defines the webGL buffer to bind
  40472. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40473. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40474. */
  40475. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40476. /**
  40477. * Disable the instance attribute corresponding to the name in parameter
  40478. * @param name defines the name of the attribute to disable
  40479. */
  40480. disableInstanceAttributeByName(name: string): void;
  40481. /**
  40482. * Disable the instance attribute corresponding to the location in parameter
  40483. * @param attributeLocation defines the attribute location of the attribute to disable
  40484. */
  40485. disableInstanceAttribute(attributeLocation: number): void;
  40486. /**
  40487. * Disable the attribute corresponding to the location in parameter
  40488. * @param attributeLocation defines the attribute location of the attribute to disable
  40489. */
  40490. disableAttributeByIndex(attributeLocation: number): void;
  40491. /**
  40492. * Send a draw order
  40493. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40494. * @param indexStart defines the starting index
  40495. * @param indexCount defines the number of index to draw
  40496. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40497. */
  40498. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40499. /**
  40500. * Draw a list of points
  40501. * @param verticesStart defines the index of first vertex to draw
  40502. * @param verticesCount defines the count of vertices to draw
  40503. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40504. */
  40505. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40506. /**
  40507. * Draw a list of unindexed primitives
  40508. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40509. * @param verticesStart defines the index of first vertex to draw
  40510. * @param verticesCount defines the count of vertices to draw
  40511. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40512. */
  40513. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40514. /**
  40515. * Draw a list of indexed primitives
  40516. * @param fillMode defines the primitive to use
  40517. * @param indexStart defines the starting index
  40518. * @param indexCount defines the number of index to draw
  40519. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40520. */
  40521. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40522. /**
  40523. * Draw a list of unindexed primitives
  40524. * @param fillMode defines the primitive to use
  40525. * @param verticesStart defines the index of first vertex to draw
  40526. * @param verticesCount defines the count of vertices to draw
  40527. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40528. */
  40529. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40530. private _drawMode;
  40531. /** @hidden */
  40532. protected _reportDrawCall(): void;
  40533. /** @hidden */
  40534. _releaseEffect(effect: Effect): void;
  40535. /** @hidden */
  40536. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40537. /**
  40538. * Create a new effect (used to store vertex/fragment shaders)
  40539. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40540. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40541. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40542. * @param samplers defines an array of string used to represent textures
  40543. * @param defines defines the string containing the defines to use to compile the shaders
  40544. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40545. * @param onCompiled defines a function to call when the effect creation is successful
  40546. * @param onError defines a function to call when the effect creation has failed
  40547. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40548. * @returns the new Effect
  40549. */
  40550. 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;
  40551. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40552. private _compileShader;
  40553. private _compileRawShader;
  40554. /** @hidden */
  40555. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40556. /**
  40557. * Directly creates a webGL program
  40558. * @param pipelineContext defines the pipeline context to attach to
  40559. * @param vertexCode defines the vertex shader code to use
  40560. * @param fragmentCode defines the fragment shader code to use
  40561. * @param context defines the webGL context to use (if not set, the current one will be used)
  40562. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40563. * @returns the new webGL program
  40564. */
  40565. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40566. /**
  40567. * Creates a webGL program
  40568. * @param pipelineContext defines the pipeline context to attach to
  40569. * @param vertexCode defines the vertex shader code to use
  40570. * @param fragmentCode defines the fragment shader code to use
  40571. * @param defines defines the string containing the defines to use to compile the shaders
  40572. * @param context defines the webGL context to use (if not set, the current one will be used)
  40573. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40574. * @returns the new webGL program
  40575. */
  40576. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40577. /**
  40578. * Creates a new pipeline context
  40579. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  40580. * @returns the new pipeline
  40581. */
  40582. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  40583. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40584. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40585. /** @hidden */
  40586. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  40587. /** @hidden */
  40588. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40589. /** @hidden */
  40590. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40591. /**
  40592. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40593. * @param pipelineContext defines the pipeline context to use
  40594. * @param uniformsNames defines the list of uniform names
  40595. * @returns an array of webGL uniform locations
  40596. */
  40597. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40598. /**
  40599. * Gets the list of active attributes for a given webGL program
  40600. * @param pipelineContext defines the pipeline context to use
  40601. * @param attributesNames defines the list of attribute names to get
  40602. * @returns an array of indices indicating the offset of each attribute
  40603. */
  40604. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40605. /**
  40606. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40607. * @param effect defines the effect to activate
  40608. */
  40609. enableEffect(effect: Nullable<Effect>): void;
  40610. /**
  40611. * Set the value of an uniform to a number (int)
  40612. * @param uniform defines the webGL uniform location where to store the value
  40613. * @param value defines the int number to store
  40614. * @returns true if the value was set
  40615. */
  40616. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40617. /**
  40618. * Set the value of an uniform to a int2
  40619. * @param uniform defines the webGL uniform location where to store the value
  40620. * @param x defines the 1st component of the value
  40621. * @param y defines the 2nd component of the value
  40622. * @returns true if the value was set
  40623. */
  40624. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40625. /**
  40626. * Set the value of an uniform to a int3
  40627. * @param uniform defines the webGL uniform location where to store the value
  40628. * @param x defines the 1st component of the value
  40629. * @param y defines the 2nd component of the value
  40630. * @param z defines the 3rd component of the value
  40631. * @returns true if the value was set
  40632. */
  40633. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40634. /**
  40635. * Set the value of an uniform to a int4
  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. * @param w defines the 4th component of the value
  40641. * @returns true if the value was set
  40642. */
  40643. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40644. /**
  40645. * Set the value of an uniform to an array of int32
  40646. * @param uniform defines the webGL uniform location where to store the value
  40647. * @param array defines the array of int32 to store
  40648. * @returns true if the value was set
  40649. */
  40650. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40651. /**
  40652. * Set the value of an uniform to an array of int32 (stored as vec2)
  40653. * @param uniform defines the webGL uniform location where to store the value
  40654. * @param array defines the array of int32 to store
  40655. * @returns true if the value was set
  40656. */
  40657. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40658. /**
  40659. * Set the value of an uniform to an array of int32 (stored as vec3)
  40660. * @param uniform defines the webGL uniform location where to store the value
  40661. * @param array defines the array of int32 to store
  40662. * @returns true if the value was set
  40663. */
  40664. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40665. /**
  40666. * Set the value of an uniform to an array of int32 (stored as vec4)
  40667. * @param uniform defines the webGL uniform location where to store the value
  40668. * @param array defines the array of int32 to store
  40669. * @returns true if the value was set
  40670. */
  40671. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40672. /**
  40673. * Set the value of an uniform to an array of number
  40674. * @param uniform defines the webGL uniform location where to store the value
  40675. * @param array defines the array of number to store
  40676. * @returns true if the value was set
  40677. */
  40678. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40679. /**
  40680. * Set the value of an uniform to an array of number (stored as vec2)
  40681. * @param uniform defines the webGL uniform location where to store the value
  40682. * @param array defines the array of number to store
  40683. * @returns true if the value was set
  40684. */
  40685. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40686. /**
  40687. * Set the value of an uniform to an array of number (stored as vec3)
  40688. * @param uniform defines the webGL uniform location where to store the value
  40689. * @param array defines the array of number to store
  40690. * @returns true if the value was set
  40691. */
  40692. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40693. /**
  40694. * Set the value of an uniform to an array of number (stored as vec4)
  40695. * @param uniform defines the webGL uniform location where to store the value
  40696. * @param array defines the array of number to store
  40697. * @returns true if the value was set
  40698. */
  40699. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40700. /**
  40701. * Set the value of an uniform to an array of float32 (stored as matrices)
  40702. * @param uniform defines the webGL uniform location where to store the value
  40703. * @param matrices defines the array of float32 to store
  40704. * @returns true if the value was set
  40705. */
  40706. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40707. /**
  40708. * Set the value of an uniform to a matrix (3x3)
  40709. * @param uniform defines the webGL uniform location where to store the value
  40710. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40711. * @returns true if the value was set
  40712. */
  40713. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40714. /**
  40715. * Set the value of an uniform to a matrix (2x2)
  40716. * @param uniform defines the webGL uniform location where to store the value
  40717. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40718. * @returns true if the value was set
  40719. */
  40720. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40721. /**
  40722. * Set the value of an uniform to a number (float)
  40723. * @param uniform defines the webGL uniform location where to store the value
  40724. * @param value defines the float number to store
  40725. * @returns true if the value was transfered
  40726. */
  40727. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40728. /**
  40729. * Set the value of an uniform to a vec2
  40730. * @param uniform defines the webGL uniform location where to store the value
  40731. * @param x defines the 1st component of the value
  40732. * @param y defines the 2nd component of the value
  40733. * @returns true if the value was set
  40734. */
  40735. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40736. /**
  40737. * Set the value of an uniform to a vec3
  40738. * @param uniform defines the webGL uniform location where to store the value
  40739. * @param x defines the 1st component of the value
  40740. * @param y defines the 2nd component of the value
  40741. * @param z defines the 3rd component of the value
  40742. * @returns true if the value was set
  40743. */
  40744. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40745. /**
  40746. * Set the value of an uniform to a vec4
  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. * @param w defines the 4th component of the value
  40752. * @returns true if the value was set
  40753. */
  40754. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40755. /**
  40756. * Apply all cached states (depth, culling, stencil and alpha)
  40757. */
  40758. applyStates(): void;
  40759. /**
  40760. * Enable or disable color writing
  40761. * @param enable defines the state to set
  40762. */
  40763. setColorWrite(enable: boolean): void;
  40764. /**
  40765. * Gets a boolean indicating if color writing is enabled
  40766. * @returns the current color writing state
  40767. */
  40768. getColorWrite(): boolean;
  40769. /**
  40770. * Gets the depth culling state manager
  40771. */
  40772. get depthCullingState(): DepthCullingState;
  40773. /**
  40774. * Gets the alpha state manager
  40775. */
  40776. get alphaState(): AlphaState;
  40777. /**
  40778. * Gets the stencil state manager
  40779. */
  40780. get stencilState(): StencilState;
  40781. /**
  40782. * Clears the list of texture accessible through engine.
  40783. * This can help preventing texture load conflict due to name collision.
  40784. */
  40785. clearInternalTexturesCache(): void;
  40786. /**
  40787. * Force the entire cache to be cleared
  40788. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40789. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40790. */
  40791. wipeCaches(bruteForce?: boolean): void;
  40792. /** @hidden */
  40793. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40794. min: number;
  40795. mag: number;
  40796. };
  40797. /** @hidden */
  40798. protected _createTexture(): WebGLTexture;
  40799. /** @hidden */
  40800. _createHardwareTexture(): HardwareTextureWrapper;
  40801. 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 | {
  40802. width: number;
  40803. height: number;
  40804. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40805. width: number;
  40806. height: number;
  40807. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40808. width: number;
  40809. height: number;
  40810. }, 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;
  40811. /**
  40812. * Usually called from Texture.ts.
  40813. * Passed information to create a WebGLTexture
  40814. * @param url defines a value which contains one of the following:
  40815. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40816. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40817. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40818. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40819. * @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)
  40820. * @param scene needed for loading to the correct scene
  40821. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40822. * @param onLoad optional callback to be called upon successful completion
  40823. * @param onError optional callback to be called upon failure
  40824. * @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
  40825. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40826. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40827. * @param forcedExtension defines the extension to use to pick the right loader
  40828. * @param mimeType defines an optional mime type
  40829. * @param loaderOptions options to be passed to the loader
  40830. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40831. */
  40832. 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;
  40833. /**
  40834. * Loads an image as an HTMLImageElement.
  40835. * @param input url string, ArrayBuffer, or Blob to load
  40836. * @param onLoad callback called when the image successfully loads
  40837. * @param onError callback called when the image fails to load
  40838. * @param offlineProvider offline provider for caching
  40839. * @param mimeType optional mime type
  40840. * @returns the HTMLImageElement of the loaded image
  40841. * @hidden
  40842. */
  40843. 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>;
  40844. /**
  40845. * @hidden
  40846. */
  40847. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40848. private _unpackFlipYCached;
  40849. /**
  40850. * In case you are sharing the context with other applications, it might
  40851. * be interested to not cache the unpack flip y state to ensure a consistent
  40852. * value would be set.
  40853. */
  40854. enableUnpackFlipYCached: boolean;
  40855. /** @hidden */
  40856. _unpackFlipY(value: boolean): void;
  40857. /** @hidden */
  40858. _getUnpackAlignement(): number;
  40859. private _getTextureTarget;
  40860. /**
  40861. * Update the sampling mode of a given texture
  40862. * @param samplingMode defines the required sampling mode
  40863. * @param texture defines the texture to update
  40864. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40865. */
  40866. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40867. /**
  40868. * Update the dimensions of a texture
  40869. * @param texture texture to update
  40870. * @param width new width of the texture
  40871. * @param height new height of the texture
  40872. * @param depth new depth of the texture
  40873. */
  40874. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  40875. /**
  40876. * Update the sampling mode of a given texture
  40877. * @param texture defines the texture to update
  40878. * @param wrapU defines the texture wrap mode of the u coordinates
  40879. * @param wrapV defines the texture wrap mode of the v coordinates
  40880. * @param wrapR defines the texture wrap mode of the r coordinates
  40881. */
  40882. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40883. /** @hidden */
  40884. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40885. width: number;
  40886. height: number;
  40887. layers?: number;
  40888. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  40889. /** @hidden */
  40890. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40891. /** @hidden */
  40892. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40893. /**
  40894. * Update a portion of an internal texture
  40895. * @param texture defines the texture to update
  40896. * @param imageData defines the data to store into the texture
  40897. * @param xOffset defines the x coordinates of the update rectangle
  40898. * @param yOffset defines the y coordinates of the update rectangle
  40899. * @param width defines the width of the update rectangle
  40900. * @param height defines the height of the update rectangle
  40901. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40902. * @param lod defines the lod level to update (0 by default)
  40903. */
  40904. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40905. /** @hidden */
  40906. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40907. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40908. private _prepareWebGLTexture;
  40909. /** @hidden */
  40910. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40911. private _getDepthStencilBuffer;
  40912. /** @hidden */
  40913. _releaseFramebufferObjects(texture: InternalTexture): void;
  40914. /** @hidden */
  40915. _releaseTexture(texture: InternalTexture): void;
  40916. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40917. protected _setProgram(program: WebGLProgram): void;
  40918. protected _boundUniforms: {
  40919. [key: number]: WebGLUniformLocation;
  40920. };
  40921. /**
  40922. * Binds an effect to the webGL context
  40923. * @param effect defines the effect to bind
  40924. */
  40925. bindSamplers(effect: Effect): void;
  40926. private _activateCurrentTexture;
  40927. /** @hidden */
  40928. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40929. /** @hidden */
  40930. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  40931. /**
  40932. * Unbind all textures from the webGL context
  40933. */
  40934. unbindAllTextures(): void;
  40935. /**
  40936. * Sets a texture to the according uniform.
  40937. * @param channel The texture channel
  40938. * @param uniform The uniform to set
  40939. * @param texture The texture to apply
  40940. * @param name The name of the uniform in the effect
  40941. */
  40942. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  40943. private _bindSamplerUniformToChannel;
  40944. private _getTextureWrapMode;
  40945. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  40946. /**
  40947. * Sets an array of texture to the webGL context
  40948. * @param channel defines the channel where the texture array must be set
  40949. * @param uniform defines the associated uniform location
  40950. * @param textures defines the array of textures to bind
  40951. * @param name name of the channel
  40952. */
  40953. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  40954. /** @hidden */
  40955. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40956. private _setTextureParameterFloat;
  40957. private _setTextureParameterInteger;
  40958. /**
  40959. * Unbind all vertex attributes from the webGL context
  40960. */
  40961. unbindAllAttributes(): void;
  40962. /**
  40963. * 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
  40964. */
  40965. releaseEffects(): void;
  40966. /**
  40967. * Dispose and release all associated resources
  40968. */
  40969. dispose(): void;
  40970. /**
  40971. * Attach a new callback raised when context lost event is fired
  40972. * @param callback defines the callback to call
  40973. */
  40974. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40975. /**
  40976. * Attach a new callback raised when context restored event is fired
  40977. * @param callback defines the callback to call
  40978. */
  40979. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40980. /**
  40981. * Get the current error code of the webGL context
  40982. * @returns the error code
  40983. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40984. */
  40985. getError(): number;
  40986. private _canRenderToFloatFramebuffer;
  40987. private _canRenderToHalfFloatFramebuffer;
  40988. private _canRenderToFramebuffer;
  40989. /** @hidden */
  40990. _getWebGLTextureType(type: number): number;
  40991. /** @hidden */
  40992. _getInternalFormat(format: number): number;
  40993. /** @hidden */
  40994. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40995. /** @hidden */
  40996. _getRGBAMultiSampleBufferFormat(type: number): number;
  40997. /** @hidden */
  40998. _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;
  40999. /**
  41000. * Loads a file from a url
  41001. * @param url url to load
  41002. * @param onSuccess callback called when the file successfully loads
  41003. * @param onProgress callback called while file is loading (if the server supports this mode)
  41004. * @param offlineProvider defines the offline provider for caching
  41005. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41006. * @param onError callback called when the file fails to load
  41007. * @returns a file request object
  41008. * @hidden
  41009. */
  41010. 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;
  41011. /**
  41012. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41013. * @param x defines the x coordinate of the rectangle where pixels must be read
  41014. * @param y defines the y coordinate of the rectangle where pixels must be read
  41015. * @param width defines the width of the rectangle where pixels must be read
  41016. * @param height defines the height of the rectangle where pixels must be read
  41017. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41018. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41019. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41020. */
  41021. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41022. private static _IsSupported;
  41023. private static _HasMajorPerformanceCaveat;
  41024. /**
  41025. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41026. */
  41027. static get IsSupported(): boolean;
  41028. /**
  41029. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41030. * @returns true if the engine can be created
  41031. * @ignorenaming
  41032. */
  41033. static isSupported(): boolean;
  41034. /**
  41035. * 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)
  41036. */
  41037. static get HasMajorPerformanceCaveat(): boolean;
  41038. /**
  41039. * Find the next highest power of two.
  41040. * @param x Number to start search from.
  41041. * @return Next highest power of two.
  41042. */
  41043. static CeilingPOT(x: number): number;
  41044. /**
  41045. * Find the next lowest power of two.
  41046. * @param x Number to start search from.
  41047. * @return Next lowest power of two.
  41048. */
  41049. static FloorPOT(x: number): number;
  41050. /**
  41051. * Find the nearest power of two.
  41052. * @param x Number to start search from.
  41053. * @return Next nearest power of two.
  41054. */
  41055. static NearestPOT(x: number): number;
  41056. /**
  41057. * Get the closest exponent of two
  41058. * @param value defines the value to approximate
  41059. * @param max defines the maximum value to return
  41060. * @param mode defines how to define the closest value
  41061. * @returns closest exponent of two of the given value
  41062. */
  41063. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41064. /**
  41065. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41066. * @param func - the function to be called
  41067. * @param requester - the object that will request the next frame. Falls back to window.
  41068. * @returns frame number
  41069. */
  41070. static QueueNewFrame(func: () => void, requester?: any): number;
  41071. /**
  41072. * Gets host document
  41073. * @returns the host document object
  41074. */
  41075. getHostDocument(): Nullable<Document>;
  41076. }
  41077. }
  41078. declare module BABYLON {
  41079. /**
  41080. * Defines the source of the internal texture
  41081. */
  41082. export enum InternalTextureSource {
  41083. /**
  41084. * The source of the texture data is unknown
  41085. */
  41086. Unknown = 0,
  41087. /**
  41088. * Texture data comes from an URL
  41089. */
  41090. Url = 1,
  41091. /**
  41092. * Texture data is only used for temporary storage
  41093. */
  41094. Temp = 2,
  41095. /**
  41096. * Texture data comes from raw data (ArrayBuffer)
  41097. */
  41098. Raw = 3,
  41099. /**
  41100. * Texture content is dynamic (video or dynamic texture)
  41101. */
  41102. Dynamic = 4,
  41103. /**
  41104. * Texture content is generated by rendering to it
  41105. */
  41106. RenderTarget = 5,
  41107. /**
  41108. * Texture content is part of a multi render target process
  41109. */
  41110. MultiRenderTarget = 6,
  41111. /**
  41112. * Texture data comes from a cube data file
  41113. */
  41114. Cube = 7,
  41115. /**
  41116. * Texture data comes from a raw cube data
  41117. */
  41118. CubeRaw = 8,
  41119. /**
  41120. * Texture data come from a prefiltered cube data file
  41121. */
  41122. CubePrefiltered = 9,
  41123. /**
  41124. * Texture content is raw 3D data
  41125. */
  41126. Raw3D = 10,
  41127. /**
  41128. * Texture content is raw 2D array data
  41129. */
  41130. Raw2DArray = 11,
  41131. /**
  41132. * Texture content is a depth texture
  41133. */
  41134. Depth = 12,
  41135. /**
  41136. * Texture data comes from a raw cube data encoded with RGBD
  41137. */
  41138. CubeRawRGBD = 13
  41139. }
  41140. /**
  41141. * Class used to store data associated with WebGL texture data for the engine
  41142. * This class should not be used directly
  41143. */
  41144. export class InternalTexture {
  41145. /** @hidden */
  41146. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41147. /**
  41148. * Defines if the texture is ready
  41149. */
  41150. isReady: boolean;
  41151. /**
  41152. * Defines if the texture is a cube texture
  41153. */
  41154. isCube: boolean;
  41155. /**
  41156. * Defines if the texture contains 3D data
  41157. */
  41158. is3D: boolean;
  41159. /**
  41160. * Defines if the texture contains 2D array data
  41161. */
  41162. is2DArray: boolean;
  41163. /**
  41164. * Defines if the texture contains multiview data
  41165. */
  41166. isMultiview: boolean;
  41167. /**
  41168. * Gets the URL used to load this texture
  41169. */
  41170. url: string;
  41171. /** @hidden */
  41172. _originalUrl: string;
  41173. /**
  41174. * Gets the sampling mode of the texture
  41175. */
  41176. samplingMode: number;
  41177. /**
  41178. * Gets a boolean indicating if the texture needs mipmaps generation
  41179. */
  41180. generateMipMaps: boolean;
  41181. /**
  41182. * Gets the number of samples used by the texture (WebGL2+ only)
  41183. */
  41184. samples: number;
  41185. /**
  41186. * Gets the type of the texture (int, float...)
  41187. */
  41188. type: number;
  41189. /**
  41190. * Gets the format of the texture (RGB, RGBA...)
  41191. */
  41192. format: number;
  41193. /**
  41194. * Observable called when the texture is loaded
  41195. */
  41196. onLoadedObservable: Observable<InternalTexture>;
  41197. /**
  41198. * Gets the width of the texture
  41199. */
  41200. width: number;
  41201. /**
  41202. * Gets the height of the texture
  41203. */
  41204. height: number;
  41205. /**
  41206. * Gets the depth of the texture
  41207. */
  41208. depth: number;
  41209. /**
  41210. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41211. */
  41212. baseWidth: number;
  41213. /**
  41214. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41215. */
  41216. baseHeight: number;
  41217. /**
  41218. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41219. */
  41220. baseDepth: number;
  41221. /**
  41222. * Gets a boolean indicating if the texture is inverted on Y axis
  41223. */
  41224. invertY: boolean;
  41225. /** @hidden */
  41226. _invertVScale: boolean;
  41227. /** @hidden */
  41228. _associatedChannel: number;
  41229. /** @hidden */
  41230. _source: InternalTextureSource;
  41231. /** @hidden */
  41232. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41233. /** @hidden */
  41234. _bufferView: Nullable<ArrayBufferView>;
  41235. /** @hidden */
  41236. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41237. /** @hidden */
  41238. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41239. /** @hidden */
  41240. _size: number;
  41241. /** @hidden */
  41242. _extension: string;
  41243. /** @hidden */
  41244. _files: Nullable<string[]>;
  41245. /** @hidden */
  41246. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41247. /** @hidden */
  41248. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41249. /** @hidden */
  41250. _framebuffer: Nullable<WebGLFramebuffer>;
  41251. /** @hidden */
  41252. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41253. /** @hidden */
  41254. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41255. /** @hidden */
  41256. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41257. /** @hidden */
  41258. _attachments: Nullable<number[]>;
  41259. /** @hidden */
  41260. _textureArray: Nullable<InternalTexture[]>;
  41261. /** @hidden */
  41262. _cachedCoordinatesMode: Nullable<number>;
  41263. /** @hidden */
  41264. _cachedWrapU: Nullable<number>;
  41265. /** @hidden */
  41266. _cachedWrapV: Nullable<number>;
  41267. /** @hidden */
  41268. _cachedWrapR: Nullable<number>;
  41269. /** @hidden */
  41270. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41271. /** @hidden */
  41272. _isDisabled: boolean;
  41273. /** @hidden */
  41274. _compression: Nullable<string>;
  41275. /** @hidden */
  41276. _generateStencilBuffer: boolean;
  41277. /** @hidden */
  41278. _generateDepthBuffer: boolean;
  41279. /** @hidden */
  41280. _comparisonFunction: number;
  41281. /** @hidden */
  41282. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41283. /** @hidden */
  41284. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41285. /** @hidden */
  41286. _sphericalPolynomialComputed: boolean;
  41287. /** @hidden */
  41288. _lodGenerationScale: number;
  41289. /** @hidden */
  41290. _lodGenerationOffset: number;
  41291. /** @hidden */
  41292. _depthStencilTexture: Nullable<InternalTexture>;
  41293. /** @hidden */
  41294. _colorTextureArray: Nullable<WebGLTexture>;
  41295. /** @hidden */
  41296. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41297. /** @hidden */
  41298. _lodTextureHigh: Nullable<BaseTexture>;
  41299. /** @hidden */
  41300. _lodTextureMid: Nullable<BaseTexture>;
  41301. /** @hidden */
  41302. _lodTextureLow: Nullable<BaseTexture>;
  41303. /** @hidden */
  41304. _isRGBD: boolean;
  41305. /** @hidden */
  41306. _linearSpecularLOD: boolean;
  41307. /** @hidden */
  41308. _irradianceTexture: Nullable<BaseTexture>;
  41309. /** @hidden */
  41310. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41311. /** @hidden */
  41312. _references: number;
  41313. /** @hidden */
  41314. _gammaSpace: Nullable<boolean>;
  41315. private _engine;
  41316. private _uniqueId;
  41317. private static _Counter;
  41318. /** Gets the unique id of the internal texture */
  41319. get uniqueId(): number;
  41320. /**
  41321. * Gets the Engine the texture belongs to.
  41322. * @returns The babylon engine
  41323. */
  41324. getEngine(): ThinEngine;
  41325. /**
  41326. * Gets the data source type of the texture
  41327. */
  41328. get source(): InternalTextureSource;
  41329. /**
  41330. * Creates a new InternalTexture
  41331. * @param engine defines the engine to use
  41332. * @param source defines the type of data that will be used
  41333. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41334. */
  41335. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41336. /**
  41337. * Increments the number of references (ie. the number of Texture that point to it)
  41338. */
  41339. incrementReferences(): void;
  41340. /**
  41341. * Change the size of the texture (not the size of the content)
  41342. * @param width defines the new width
  41343. * @param height defines the new height
  41344. * @param depth defines the new depth (1 by default)
  41345. */
  41346. updateSize(width: int, height: int, depth?: int): void;
  41347. /** @hidden */
  41348. _rebuild(): void;
  41349. /** @hidden */
  41350. _swapAndDie(target: InternalTexture): void;
  41351. /**
  41352. * Dispose the current allocated resources
  41353. */
  41354. dispose(): void;
  41355. }
  41356. }
  41357. declare module BABYLON {
  41358. /**
  41359. * Interface used to present a loading screen while loading a scene
  41360. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41361. */
  41362. export interface ILoadingScreen {
  41363. /**
  41364. * Function called to display the loading screen
  41365. */
  41366. displayLoadingUI: () => void;
  41367. /**
  41368. * Function called to hide the loading screen
  41369. */
  41370. hideLoadingUI: () => void;
  41371. /**
  41372. * Gets or sets the color to use for the background
  41373. */
  41374. loadingUIBackgroundColor: string;
  41375. /**
  41376. * Gets or sets the text to display while loading
  41377. */
  41378. loadingUIText: string;
  41379. }
  41380. /**
  41381. * Class used for the default loading screen
  41382. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41383. */
  41384. export class DefaultLoadingScreen implements ILoadingScreen {
  41385. private _renderingCanvas;
  41386. private _loadingText;
  41387. private _loadingDivBackgroundColor;
  41388. private _loadingDiv;
  41389. private _loadingTextDiv;
  41390. /** Gets or sets the logo url to use for the default loading screen */
  41391. static DefaultLogoUrl: string;
  41392. /** Gets or sets the spinner url to use for the default loading screen */
  41393. static DefaultSpinnerUrl: string;
  41394. /**
  41395. * Creates a new default loading screen
  41396. * @param _renderingCanvas defines the canvas used to render the scene
  41397. * @param _loadingText defines the default text to display
  41398. * @param _loadingDivBackgroundColor defines the default background color
  41399. */
  41400. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41401. /**
  41402. * Function called to display the loading screen
  41403. */
  41404. displayLoadingUI(): void;
  41405. /**
  41406. * Function called to hide the loading screen
  41407. */
  41408. hideLoadingUI(): void;
  41409. /**
  41410. * Gets or sets the text to display while loading
  41411. */
  41412. set loadingUIText(text: string);
  41413. get loadingUIText(): string;
  41414. /**
  41415. * Gets or sets the color to use for the background
  41416. */
  41417. get loadingUIBackgroundColor(): string;
  41418. set loadingUIBackgroundColor(color: string);
  41419. private _resizeLoadingUI;
  41420. }
  41421. }
  41422. declare module BABYLON {
  41423. /**
  41424. * Interface for any object that can request an animation frame
  41425. */
  41426. export interface ICustomAnimationFrameRequester {
  41427. /**
  41428. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41429. */
  41430. renderFunction?: Function;
  41431. /**
  41432. * Called to request the next frame to render to
  41433. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41434. */
  41435. requestAnimationFrame: Function;
  41436. /**
  41437. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41438. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41439. */
  41440. requestID?: number;
  41441. }
  41442. }
  41443. declare module BABYLON {
  41444. /**
  41445. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41446. */
  41447. export class PerformanceMonitor {
  41448. private _enabled;
  41449. private _rollingFrameTime;
  41450. private _lastFrameTimeMs;
  41451. /**
  41452. * constructor
  41453. * @param frameSampleSize The number of samples required to saturate the sliding window
  41454. */
  41455. constructor(frameSampleSize?: number);
  41456. /**
  41457. * Samples current frame
  41458. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41459. */
  41460. sampleFrame(timeMs?: number): void;
  41461. /**
  41462. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41463. */
  41464. get averageFrameTime(): number;
  41465. /**
  41466. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41467. */
  41468. get averageFrameTimeVariance(): number;
  41469. /**
  41470. * Returns the frame time of the most recent frame
  41471. */
  41472. get instantaneousFrameTime(): number;
  41473. /**
  41474. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41475. */
  41476. get averageFPS(): number;
  41477. /**
  41478. * Returns the average framerate in frames per second using the most recent frame time
  41479. */
  41480. get instantaneousFPS(): number;
  41481. /**
  41482. * Returns true if enough samples have been taken to completely fill the sliding window
  41483. */
  41484. get isSaturated(): boolean;
  41485. /**
  41486. * Enables contributions to the sliding window sample set
  41487. */
  41488. enable(): void;
  41489. /**
  41490. * Disables contributions to the sliding window sample set
  41491. * Samples will not be interpolated over the disabled period
  41492. */
  41493. disable(): void;
  41494. /**
  41495. * Returns true if sampling is enabled
  41496. */
  41497. get isEnabled(): boolean;
  41498. /**
  41499. * Resets performance monitor
  41500. */
  41501. reset(): void;
  41502. }
  41503. /**
  41504. * RollingAverage
  41505. *
  41506. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41507. */
  41508. export class RollingAverage {
  41509. /**
  41510. * Current average
  41511. */
  41512. average: number;
  41513. /**
  41514. * Current variance
  41515. */
  41516. variance: number;
  41517. protected _samples: Array<number>;
  41518. protected _sampleCount: number;
  41519. protected _pos: number;
  41520. protected _m2: number;
  41521. /**
  41522. * constructor
  41523. * @param length The number of samples required to saturate the sliding window
  41524. */
  41525. constructor(length: number);
  41526. /**
  41527. * Adds a sample to the sample set
  41528. * @param v The sample value
  41529. */
  41530. add(v: number): void;
  41531. /**
  41532. * Returns previously added values or null if outside of history or outside the sliding window domain
  41533. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41534. * @return Value previously recorded with add() or null if outside of range
  41535. */
  41536. history(i: number): number;
  41537. /**
  41538. * Returns true if enough samples have been taken to completely fill the sliding window
  41539. * @return true if sample-set saturated
  41540. */
  41541. isSaturated(): boolean;
  41542. /**
  41543. * Resets the rolling average (equivalent to 0 samples taken so far)
  41544. */
  41545. reset(): void;
  41546. /**
  41547. * Wraps a value around the sample range boundaries
  41548. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41549. * @return Wrapped position in sample range
  41550. */
  41551. protected _wrapPosition(i: number): number;
  41552. }
  41553. }
  41554. declare module BABYLON {
  41555. /**
  41556. * This class is used to track a performance counter which is number based.
  41557. * The user has access to many properties which give statistics of different nature.
  41558. *
  41559. * The implementer can track two kinds of Performance Counter: time and count.
  41560. * 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.
  41561. * 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.
  41562. */
  41563. export class PerfCounter {
  41564. /**
  41565. * Gets or sets a global boolean to turn on and off all the counters
  41566. */
  41567. static Enabled: boolean;
  41568. /**
  41569. * Returns the smallest value ever
  41570. */
  41571. get min(): number;
  41572. /**
  41573. * Returns the biggest value ever
  41574. */
  41575. get max(): number;
  41576. /**
  41577. * Returns the average value since the performance counter is running
  41578. */
  41579. get average(): number;
  41580. /**
  41581. * Returns the average value of the last second the counter was monitored
  41582. */
  41583. get lastSecAverage(): number;
  41584. /**
  41585. * Returns the current value
  41586. */
  41587. get current(): number;
  41588. /**
  41589. * Gets the accumulated total
  41590. */
  41591. get total(): number;
  41592. /**
  41593. * Gets the total value count
  41594. */
  41595. get count(): number;
  41596. /**
  41597. * Creates a new counter
  41598. */
  41599. constructor();
  41600. /**
  41601. * Call this method to start monitoring a new frame.
  41602. * 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.
  41603. */
  41604. fetchNewFrame(): void;
  41605. /**
  41606. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41607. * @param newCount the count value to add to the monitored count
  41608. * @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.
  41609. */
  41610. addCount(newCount: number, fetchResult: boolean): void;
  41611. /**
  41612. * Start monitoring this performance counter
  41613. */
  41614. beginMonitoring(): void;
  41615. /**
  41616. * Compute the time lapsed since the previous beginMonitoring() call.
  41617. * @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
  41618. */
  41619. endMonitoring(newFrame?: boolean): void;
  41620. private _fetchResult;
  41621. private _startMonitoringTime;
  41622. private _min;
  41623. private _max;
  41624. private _average;
  41625. private _current;
  41626. private _totalValueCount;
  41627. private _totalAccumulated;
  41628. private _lastSecAverage;
  41629. private _lastSecAccumulated;
  41630. private _lastSecTime;
  41631. private _lastSecValueCount;
  41632. }
  41633. }
  41634. declare module BABYLON {
  41635. interface ThinEngine {
  41636. /** @hidden */
  41637. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41638. }
  41639. }
  41640. declare module BABYLON {
  41641. /**
  41642. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41643. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41644. */
  41645. export class Analyser {
  41646. /**
  41647. * Gets or sets the smoothing
  41648. * @ignorenaming
  41649. */
  41650. SMOOTHING: number;
  41651. /**
  41652. * Gets or sets the FFT table size
  41653. * @ignorenaming
  41654. */
  41655. FFT_SIZE: number;
  41656. /**
  41657. * Gets or sets the bar graph amplitude
  41658. * @ignorenaming
  41659. */
  41660. BARGRAPHAMPLITUDE: number;
  41661. /**
  41662. * Gets or sets the position of the debug canvas
  41663. * @ignorenaming
  41664. */
  41665. DEBUGCANVASPOS: {
  41666. x: number;
  41667. y: number;
  41668. };
  41669. /**
  41670. * Gets or sets the debug canvas size
  41671. * @ignorenaming
  41672. */
  41673. DEBUGCANVASSIZE: {
  41674. width: number;
  41675. height: number;
  41676. };
  41677. private _byteFreqs;
  41678. private _byteTime;
  41679. private _floatFreqs;
  41680. private _webAudioAnalyser;
  41681. private _debugCanvas;
  41682. private _debugCanvasContext;
  41683. private _scene;
  41684. private _registerFunc;
  41685. private _audioEngine;
  41686. /**
  41687. * Creates a new analyser
  41688. * @param scene defines hosting scene
  41689. */
  41690. constructor(scene: Scene);
  41691. /**
  41692. * Get the number of data values you will have to play with for the visualization
  41693. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41694. * @returns a number
  41695. */
  41696. getFrequencyBinCount(): number;
  41697. /**
  41698. * Gets the current frequency data as a byte array
  41699. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41700. * @returns a Uint8Array
  41701. */
  41702. getByteFrequencyData(): Uint8Array;
  41703. /**
  41704. * Gets the current waveform as a byte array
  41705. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41706. * @returns a Uint8Array
  41707. */
  41708. getByteTimeDomainData(): Uint8Array;
  41709. /**
  41710. * Gets the current frequency data as a float array
  41711. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41712. * @returns a Float32Array
  41713. */
  41714. getFloatFrequencyData(): Float32Array;
  41715. /**
  41716. * Renders the debug canvas
  41717. */
  41718. drawDebugCanvas(): void;
  41719. /**
  41720. * Stops rendering the debug canvas and removes it
  41721. */
  41722. stopDebugCanvas(): void;
  41723. /**
  41724. * Connects two audio nodes
  41725. * @param inputAudioNode defines first node to connect
  41726. * @param outputAudioNode defines second node to connect
  41727. */
  41728. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41729. /**
  41730. * Releases all associated resources
  41731. */
  41732. dispose(): void;
  41733. }
  41734. }
  41735. declare module BABYLON {
  41736. /**
  41737. * This represents an audio engine and it is responsible
  41738. * to play, synchronize and analyse sounds throughout the application.
  41739. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41740. */
  41741. export interface IAudioEngine extends IDisposable {
  41742. /**
  41743. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41744. */
  41745. readonly canUseWebAudio: boolean;
  41746. /**
  41747. * Gets the current AudioContext if available.
  41748. */
  41749. readonly audioContext: Nullable<AudioContext>;
  41750. /**
  41751. * The master gain node defines the global audio volume of your audio engine.
  41752. */
  41753. readonly masterGain: GainNode;
  41754. /**
  41755. * Gets whether or not mp3 are supported by your browser.
  41756. */
  41757. readonly isMP3supported: boolean;
  41758. /**
  41759. * Gets whether or not ogg are supported by your browser.
  41760. */
  41761. readonly isOGGsupported: boolean;
  41762. /**
  41763. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41764. * @ignoreNaming
  41765. */
  41766. WarnedWebAudioUnsupported: boolean;
  41767. /**
  41768. * Defines if the audio engine relies on a custom unlocked button.
  41769. * In this case, the embedded button will not be displayed.
  41770. */
  41771. useCustomUnlockedButton: boolean;
  41772. /**
  41773. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41774. */
  41775. readonly unlocked: boolean;
  41776. /**
  41777. * Event raised when audio has been unlocked on the browser.
  41778. */
  41779. onAudioUnlockedObservable: Observable<IAudioEngine>;
  41780. /**
  41781. * Event raised when audio has been locked on the browser.
  41782. */
  41783. onAudioLockedObservable: Observable<IAudioEngine>;
  41784. /**
  41785. * Flags the audio engine in Locked state.
  41786. * This happens due to new browser policies preventing audio to autoplay.
  41787. */
  41788. lock(): void;
  41789. /**
  41790. * Unlocks the audio engine once a user action has been done on the dom.
  41791. * This is helpful to resume play once browser policies have been satisfied.
  41792. */
  41793. unlock(): void;
  41794. /**
  41795. * Gets the global volume sets on the master gain.
  41796. * @returns the global volume if set or -1 otherwise
  41797. */
  41798. getGlobalVolume(): number;
  41799. /**
  41800. * Sets the global volume of your experience (sets on the master gain).
  41801. * @param newVolume Defines the new global volume of the application
  41802. */
  41803. setGlobalVolume(newVolume: number): void;
  41804. /**
  41805. * Connect the audio engine to an audio analyser allowing some amazing
  41806. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41807. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41808. * @param analyser The analyser to connect to the engine
  41809. */
  41810. connectToAnalyser(analyser: Analyser): void;
  41811. }
  41812. }
  41813. declare module BABYLON {
  41814. /**
  41815. * Defines the interface used by display changed events
  41816. */
  41817. export interface IDisplayChangedEventArgs {
  41818. /** Gets the vrDisplay object (if any) */
  41819. vrDisplay: Nullable<any>;
  41820. /** Gets a boolean indicating if webVR is supported */
  41821. vrSupported: boolean;
  41822. }
  41823. /**
  41824. * Defines the interface used by objects containing a viewport (like a camera)
  41825. */
  41826. interface IViewportOwnerLike {
  41827. /**
  41828. * Gets or sets the viewport
  41829. */
  41830. viewport: IViewportLike;
  41831. }
  41832. /**
  41833. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41834. */
  41835. export class Engine extends ThinEngine {
  41836. /** Defines that alpha blending is disabled */
  41837. static readonly ALPHA_DISABLE: number;
  41838. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41839. static readonly ALPHA_ADD: number;
  41840. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41841. static readonly ALPHA_COMBINE: number;
  41842. /** Defines that alpha blending to DEST - SRC * DEST */
  41843. static readonly ALPHA_SUBTRACT: number;
  41844. /** Defines that alpha blending to SRC * DEST */
  41845. static readonly ALPHA_MULTIPLY: number;
  41846. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41847. static readonly ALPHA_MAXIMIZED: number;
  41848. /** Defines that alpha blending to SRC + DEST */
  41849. static readonly ALPHA_ONEONE: number;
  41850. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41851. static readonly ALPHA_PREMULTIPLIED: number;
  41852. /**
  41853. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41854. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41855. */
  41856. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41857. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41858. static readonly ALPHA_INTERPOLATE: number;
  41859. /**
  41860. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41861. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41862. */
  41863. static readonly ALPHA_SCREENMODE: number;
  41864. /** Defines that the ressource is not delayed*/
  41865. static readonly DELAYLOADSTATE_NONE: number;
  41866. /** Defines that the ressource was successfully delay loaded */
  41867. static readonly DELAYLOADSTATE_LOADED: number;
  41868. /** Defines that the ressource is currently delay loading */
  41869. static readonly DELAYLOADSTATE_LOADING: number;
  41870. /** Defines that the ressource is delayed and has not started loading */
  41871. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41872. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41873. static readonly NEVER: number;
  41874. /** 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 */
  41875. static readonly ALWAYS: number;
  41876. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41877. static readonly LESS: number;
  41878. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41879. static readonly EQUAL: number;
  41880. /** 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 */
  41881. static readonly LEQUAL: number;
  41882. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41883. static readonly GREATER: number;
  41884. /** 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 */
  41885. static readonly GEQUAL: number;
  41886. /** 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 */
  41887. static readonly NOTEQUAL: number;
  41888. /** Passed to stencilOperation to specify that stencil value must be kept */
  41889. static readonly KEEP: number;
  41890. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41891. static readonly REPLACE: number;
  41892. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41893. static readonly INCR: number;
  41894. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41895. static readonly DECR: number;
  41896. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41897. static readonly INVERT: number;
  41898. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41899. static readonly INCR_WRAP: number;
  41900. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41901. static readonly DECR_WRAP: number;
  41902. /** Texture is not repeating outside of 0..1 UVs */
  41903. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41904. /** Texture is repeating outside of 0..1 UVs */
  41905. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41906. /** Texture is repeating and mirrored */
  41907. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41908. /** ALPHA */
  41909. static readonly TEXTUREFORMAT_ALPHA: number;
  41910. /** LUMINANCE */
  41911. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41912. /** LUMINANCE_ALPHA */
  41913. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41914. /** RGB */
  41915. static readonly TEXTUREFORMAT_RGB: number;
  41916. /** RGBA */
  41917. static readonly TEXTUREFORMAT_RGBA: number;
  41918. /** RED */
  41919. static readonly TEXTUREFORMAT_RED: number;
  41920. /** RED (2nd reference) */
  41921. static readonly TEXTUREFORMAT_R: number;
  41922. /** RG */
  41923. static readonly TEXTUREFORMAT_RG: number;
  41924. /** RED_INTEGER */
  41925. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41926. /** RED_INTEGER (2nd reference) */
  41927. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41928. /** RG_INTEGER */
  41929. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41930. /** RGB_INTEGER */
  41931. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41932. /** RGBA_INTEGER */
  41933. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41934. /** UNSIGNED_BYTE */
  41935. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41936. /** UNSIGNED_BYTE (2nd reference) */
  41937. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41938. /** FLOAT */
  41939. static readonly TEXTURETYPE_FLOAT: number;
  41940. /** HALF_FLOAT */
  41941. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41942. /** BYTE */
  41943. static readonly TEXTURETYPE_BYTE: number;
  41944. /** SHORT */
  41945. static readonly TEXTURETYPE_SHORT: number;
  41946. /** UNSIGNED_SHORT */
  41947. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41948. /** INT */
  41949. static readonly TEXTURETYPE_INT: number;
  41950. /** UNSIGNED_INT */
  41951. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41952. /** UNSIGNED_SHORT_4_4_4_4 */
  41953. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  41954. /** UNSIGNED_SHORT_5_5_5_1 */
  41955. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41956. /** UNSIGNED_SHORT_5_6_5 */
  41957. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41958. /** UNSIGNED_INT_2_10_10_10_REV */
  41959. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41960. /** UNSIGNED_INT_24_8 */
  41961. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41962. /** UNSIGNED_INT_10F_11F_11F_REV */
  41963. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  41964. /** UNSIGNED_INT_5_9_9_9_REV */
  41965. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  41966. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  41967. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  41968. /** nearest is mag = nearest and min = nearest and mip = none */
  41969. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  41970. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41971. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  41972. /** Trilinear is mag = linear and min = linear and mip = linear */
  41973. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  41974. /** nearest is mag = nearest and min = nearest and mip = linear */
  41975. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  41976. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41977. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  41978. /** Trilinear is mag = linear and min = linear and mip = linear */
  41979. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  41980. /** mag = nearest and min = nearest and mip = nearest */
  41981. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41982. /** mag = nearest and min = linear and mip = nearest */
  41983. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41984. /** mag = nearest and min = linear and mip = linear */
  41985. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  41986. /** mag = nearest and min = linear and mip = none */
  41987. static readonly TEXTURE_NEAREST_LINEAR: number;
  41988. /** mag = nearest and min = nearest and mip = none */
  41989. static readonly TEXTURE_NEAREST_NEAREST: number;
  41990. /** mag = linear and min = nearest and mip = nearest */
  41991. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  41992. /** mag = linear and min = nearest and mip = linear */
  41993. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  41994. /** mag = linear and min = linear and mip = none */
  41995. static readonly TEXTURE_LINEAR_LINEAR: number;
  41996. /** mag = linear and min = nearest and mip = none */
  41997. static readonly TEXTURE_LINEAR_NEAREST: number;
  41998. /** Explicit coordinates mode */
  41999. static readonly TEXTURE_EXPLICIT_MODE: number;
  42000. /** Spherical coordinates mode */
  42001. static readonly TEXTURE_SPHERICAL_MODE: number;
  42002. /** Planar coordinates mode */
  42003. static readonly TEXTURE_PLANAR_MODE: number;
  42004. /** Cubic coordinates mode */
  42005. static readonly TEXTURE_CUBIC_MODE: number;
  42006. /** Projection coordinates mode */
  42007. static readonly TEXTURE_PROJECTION_MODE: number;
  42008. /** Skybox coordinates mode */
  42009. static readonly TEXTURE_SKYBOX_MODE: number;
  42010. /** Inverse Cubic coordinates mode */
  42011. static readonly TEXTURE_INVCUBIC_MODE: number;
  42012. /** Equirectangular coordinates mode */
  42013. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42014. /** Equirectangular Fixed coordinates mode */
  42015. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42016. /** Equirectangular Fixed Mirrored coordinates mode */
  42017. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42018. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42019. static readonly SCALEMODE_FLOOR: number;
  42020. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42021. static readonly SCALEMODE_NEAREST: number;
  42022. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42023. static readonly SCALEMODE_CEILING: number;
  42024. /**
  42025. * Returns the current npm package of the sdk
  42026. */
  42027. static get NpmPackage(): string;
  42028. /**
  42029. * Returns the current version of the framework
  42030. */
  42031. static get Version(): string;
  42032. /** Gets the list of created engines */
  42033. static get Instances(): Engine[];
  42034. /**
  42035. * Gets the latest created engine
  42036. */
  42037. static get LastCreatedEngine(): Nullable<Engine>;
  42038. /**
  42039. * Gets the latest created scene
  42040. */
  42041. static get LastCreatedScene(): Nullable<Scene>;
  42042. /**
  42043. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42044. * @param flag defines which part of the materials must be marked as dirty
  42045. * @param predicate defines a predicate used to filter which materials should be affected
  42046. */
  42047. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42048. /**
  42049. * Method called to create the default loading screen.
  42050. * This can be overriden in your own app.
  42051. * @param canvas The rendering canvas element
  42052. * @returns The loading screen
  42053. */
  42054. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42055. /**
  42056. * Method called to create the default rescale post process on each engine.
  42057. */
  42058. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42059. /**
  42060. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42061. **/
  42062. enableOfflineSupport: boolean;
  42063. /**
  42064. * 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)
  42065. **/
  42066. disableManifestCheck: boolean;
  42067. /**
  42068. * Gets the list of created scenes
  42069. */
  42070. scenes: Scene[];
  42071. /**
  42072. * Event raised when a new scene is created
  42073. */
  42074. onNewSceneAddedObservable: Observable<Scene>;
  42075. /**
  42076. * Gets the list of created postprocesses
  42077. */
  42078. postProcesses: PostProcess[];
  42079. /**
  42080. * Gets a boolean indicating if the pointer is currently locked
  42081. */
  42082. isPointerLock: boolean;
  42083. /**
  42084. * Observable event triggered each time the rendering canvas is resized
  42085. */
  42086. onResizeObservable: Observable<Engine>;
  42087. /**
  42088. * Observable event triggered each time the canvas loses focus
  42089. */
  42090. onCanvasBlurObservable: Observable<Engine>;
  42091. /**
  42092. * Observable event triggered each time the canvas gains focus
  42093. */
  42094. onCanvasFocusObservable: Observable<Engine>;
  42095. /**
  42096. * Observable event triggered each time the canvas receives pointerout event
  42097. */
  42098. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42099. /**
  42100. * Observable raised when the engine begins a new frame
  42101. */
  42102. onBeginFrameObservable: Observable<Engine>;
  42103. /**
  42104. * If set, will be used to request the next animation frame for the render loop
  42105. */
  42106. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42107. /**
  42108. * Observable raised when the engine ends the current frame
  42109. */
  42110. onEndFrameObservable: Observable<Engine>;
  42111. /**
  42112. * Observable raised when the engine is about to compile a shader
  42113. */
  42114. onBeforeShaderCompilationObservable: Observable<Engine>;
  42115. /**
  42116. * Observable raised when the engine has jsut compiled a shader
  42117. */
  42118. onAfterShaderCompilationObservable: Observable<Engine>;
  42119. /**
  42120. * Gets the audio engine
  42121. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42122. * @ignorenaming
  42123. */
  42124. static audioEngine: IAudioEngine;
  42125. /**
  42126. * Default AudioEngine factory responsible of creating the Audio Engine.
  42127. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42128. */
  42129. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42130. /**
  42131. * Default offline support factory responsible of creating a tool used to store data locally.
  42132. * By default, this will create a Database object if the workload has been embedded.
  42133. */
  42134. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42135. private _loadingScreen;
  42136. private _pointerLockRequested;
  42137. private _rescalePostProcess;
  42138. protected _deterministicLockstep: boolean;
  42139. protected _lockstepMaxSteps: number;
  42140. protected _timeStep: number;
  42141. protected get _supportsHardwareTextureRescaling(): boolean;
  42142. private _fps;
  42143. private _deltaTime;
  42144. /** @hidden */
  42145. _drawCalls: PerfCounter;
  42146. /** 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 */
  42147. canvasTabIndex: number;
  42148. /**
  42149. * Turn this value on if you want to pause FPS computation when in background
  42150. */
  42151. disablePerformanceMonitorInBackground: boolean;
  42152. private _performanceMonitor;
  42153. /**
  42154. * Gets the performance monitor attached to this engine
  42155. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42156. */
  42157. get performanceMonitor(): PerformanceMonitor;
  42158. private _onFocus;
  42159. private _onBlur;
  42160. private _onCanvasPointerOut;
  42161. private _onCanvasBlur;
  42162. private _onCanvasFocus;
  42163. private _onFullscreenChange;
  42164. private _onPointerLockChange;
  42165. /**
  42166. * Gets the HTML element used to attach event listeners
  42167. * @returns a HTML element
  42168. */
  42169. getInputElement(): Nullable<HTMLElement>;
  42170. /**
  42171. * Creates a new engine
  42172. * @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
  42173. * @param antialias defines enable antialiasing (default: false)
  42174. * @param options defines further options to be sent to the getContext() function
  42175. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42176. */
  42177. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42178. /**
  42179. * Shared initialization across engines types.
  42180. * @param canvas The canvas associated with this instance of the engine.
  42181. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42182. * @param audioEngine Defines if an audio engine should be created by default
  42183. */
  42184. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42185. /**
  42186. * Gets current aspect ratio
  42187. * @param viewportOwner defines the camera to use to get the aspect ratio
  42188. * @param useScreen defines if screen size must be used (or the current render target if any)
  42189. * @returns a number defining the aspect ratio
  42190. */
  42191. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42192. /**
  42193. * Gets current screen aspect ratio
  42194. * @returns a number defining the aspect ratio
  42195. */
  42196. getScreenAspectRatio(): number;
  42197. /**
  42198. * Gets the client rect of the HTML canvas attached with the current webGL context
  42199. * @returns a client rectanglee
  42200. */
  42201. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42202. /**
  42203. * Gets the client rect of the HTML element used for events
  42204. * @returns a client rectanglee
  42205. */
  42206. getInputElementClientRect(): Nullable<ClientRect>;
  42207. /**
  42208. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42209. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42210. * @returns true if engine is in deterministic lock step mode
  42211. */
  42212. isDeterministicLockStep(): boolean;
  42213. /**
  42214. * Gets the max steps when engine is running in deterministic lock step
  42215. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42216. * @returns the max steps
  42217. */
  42218. getLockstepMaxSteps(): number;
  42219. /**
  42220. * Returns the time in ms between steps when using deterministic lock step.
  42221. * @returns time step in (ms)
  42222. */
  42223. getTimeStep(): number;
  42224. /**
  42225. * Force the mipmap generation for the given render target texture
  42226. * @param texture defines the render target texture to use
  42227. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42228. */
  42229. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42230. /** States */
  42231. /**
  42232. * Set various states to the webGL context
  42233. * @param culling defines backface culling state
  42234. * @param zOffset defines the value to apply to zOffset (0 by default)
  42235. * @param force defines if states must be applied even if cache is up to date
  42236. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42237. */
  42238. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42239. /**
  42240. * Set the z offset to apply to current rendering
  42241. * @param value defines the offset to apply
  42242. */
  42243. setZOffset(value: number): void;
  42244. /**
  42245. * Gets the current value of the zOffset
  42246. * @returns the current zOffset state
  42247. */
  42248. getZOffset(): number;
  42249. /**
  42250. * Gets a boolean indicating if depth testing is enabled
  42251. * @returns the current state
  42252. */
  42253. getDepthBuffer(): boolean;
  42254. /**
  42255. * Enable or disable depth buffering
  42256. * @param enable defines the state to set
  42257. */
  42258. setDepthBuffer(enable: boolean): void;
  42259. /**
  42260. * Gets a boolean indicating if depth writing is enabled
  42261. * @returns the current depth writing state
  42262. */
  42263. getDepthWrite(): boolean;
  42264. /**
  42265. * Enable or disable depth writing
  42266. * @param enable defines the state to set
  42267. */
  42268. setDepthWrite(enable: boolean): void;
  42269. /**
  42270. * Gets a boolean indicating if stencil buffer is enabled
  42271. * @returns the current stencil buffer state
  42272. */
  42273. getStencilBuffer(): boolean;
  42274. /**
  42275. * Enable or disable the stencil buffer
  42276. * @param enable defines if the stencil buffer must be enabled or disabled
  42277. */
  42278. setStencilBuffer(enable: boolean): void;
  42279. /**
  42280. * Gets the current stencil mask
  42281. * @returns a number defining the new stencil mask to use
  42282. */
  42283. getStencilMask(): number;
  42284. /**
  42285. * Sets the current stencil mask
  42286. * @param mask defines the new stencil mask to use
  42287. */
  42288. setStencilMask(mask: number): void;
  42289. /**
  42290. * Gets the current stencil function
  42291. * @returns a number defining the stencil function to use
  42292. */
  42293. getStencilFunction(): number;
  42294. /**
  42295. * Gets the current stencil reference value
  42296. * @returns a number defining the stencil reference value to use
  42297. */
  42298. getStencilFunctionReference(): number;
  42299. /**
  42300. * Gets the current stencil mask
  42301. * @returns a number defining the stencil mask to use
  42302. */
  42303. getStencilFunctionMask(): number;
  42304. /**
  42305. * Sets the current stencil function
  42306. * @param stencilFunc defines the new stencil function to use
  42307. */
  42308. setStencilFunction(stencilFunc: number): void;
  42309. /**
  42310. * Sets the current stencil reference
  42311. * @param reference defines the new stencil reference to use
  42312. */
  42313. setStencilFunctionReference(reference: number): void;
  42314. /**
  42315. * Sets the current stencil mask
  42316. * @param mask defines the new stencil mask to use
  42317. */
  42318. setStencilFunctionMask(mask: number): void;
  42319. /**
  42320. * Gets the current stencil operation when stencil fails
  42321. * @returns a number defining stencil operation to use when stencil fails
  42322. */
  42323. getStencilOperationFail(): number;
  42324. /**
  42325. * Gets the current stencil operation when depth fails
  42326. * @returns a number defining stencil operation to use when depth fails
  42327. */
  42328. getStencilOperationDepthFail(): number;
  42329. /**
  42330. * Gets the current stencil operation when stencil passes
  42331. * @returns a number defining stencil operation to use when stencil passes
  42332. */
  42333. getStencilOperationPass(): number;
  42334. /**
  42335. * Sets the stencil operation to use when stencil fails
  42336. * @param operation defines the stencil operation to use when stencil fails
  42337. */
  42338. setStencilOperationFail(operation: number): void;
  42339. /**
  42340. * Sets the stencil operation to use when depth fails
  42341. * @param operation defines the stencil operation to use when depth fails
  42342. */
  42343. setStencilOperationDepthFail(operation: number): void;
  42344. /**
  42345. * Sets the stencil operation to use when stencil passes
  42346. * @param operation defines the stencil operation to use when stencil passes
  42347. */
  42348. setStencilOperationPass(operation: number): void;
  42349. /**
  42350. * Sets a boolean indicating if the dithering state is enabled or disabled
  42351. * @param value defines the dithering state
  42352. */
  42353. setDitheringState(value: boolean): void;
  42354. /**
  42355. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42356. * @param value defines the rasterizer state
  42357. */
  42358. setRasterizerState(value: boolean): void;
  42359. /**
  42360. * Gets the current depth function
  42361. * @returns a number defining the depth function
  42362. */
  42363. getDepthFunction(): Nullable<number>;
  42364. /**
  42365. * Sets the current depth function
  42366. * @param depthFunc defines the function to use
  42367. */
  42368. setDepthFunction(depthFunc: number): void;
  42369. /**
  42370. * Sets the current depth function to GREATER
  42371. */
  42372. setDepthFunctionToGreater(): void;
  42373. /**
  42374. * Sets the current depth function to GEQUAL
  42375. */
  42376. setDepthFunctionToGreaterOrEqual(): void;
  42377. /**
  42378. * Sets the current depth function to LESS
  42379. */
  42380. setDepthFunctionToLess(): void;
  42381. /**
  42382. * Sets the current depth function to LEQUAL
  42383. */
  42384. setDepthFunctionToLessOrEqual(): void;
  42385. private _cachedStencilBuffer;
  42386. private _cachedStencilFunction;
  42387. private _cachedStencilMask;
  42388. private _cachedStencilOperationPass;
  42389. private _cachedStencilOperationFail;
  42390. private _cachedStencilOperationDepthFail;
  42391. private _cachedStencilReference;
  42392. /**
  42393. * Caches the the state of the stencil buffer
  42394. */
  42395. cacheStencilState(): void;
  42396. /**
  42397. * Restores the state of the stencil buffer
  42398. */
  42399. restoreStencilState(): void;
  42400. /**
  42401. * Directly set the WebGL Viewport
  42402. * @param x defines the x coordinate of the viewport (in screen space)
  42403. * @param y defines the y coordinate of the viewport (in screen space)
  42404. * @param width defines the width of the viewport (in screen space)
  42405. * @param height defines the height of the viewport (in screen space)
  42406. * @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
  42407. */
  42408. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42409. /**
  42410. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42411. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42412. * @param y defines the y-coordinate of the corner of the clear rectangle
  42413. * @param width defines the width of the clear rectangle
  42414. * @param height defines the height of the clear rectangle
  42415. * @param clearColor defines the clear color
  42416. */
  42417. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42418. /**
  42419. * Enable scissor test on a specific rectangle (ie. render will only be executed 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. */
  42425. enableScissor(x: number, y: number, width: number, height: number): void;
  42426. /**
  42427. * Disable previously set scissor test rectangle
  42428. */
  42429. disableScissor(): void;
  42430. protected _reportDrawCall(): void;
  42431. /**
  42432. * Initializes a webVR display and starts listening to display change events
  42433. * The onVRDisplayChangedObservable will be notified upon these changes
  42434. * @returns The onVRDisplayChangedObservable
  42435. */
  42436. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42437. /** @hidden */
  42438. _prepareVRComponent(): void;
  42439. /** @hidden */
  42440. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42441. /** @hidden */
  42442. _submitVRFrame(): void;
  42443. /**
  42444. * Call this function to leave webVR mode
  42445. * Will do nothing if webVR is not supported or if there is no webVR device
  42446. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42447. */
  42448. disableVR(): void;
  42449. /**
  42450. * Gets a boolean indicating that the system is in VR mode and is presenting
  42451. * @returns true if VR mode is engaged
  42452. */
  42453. isVRPresenting(): boolean;
  42454. /** @hidden */
  42455. _requestVRFrame(): void;
  42456. /** @hidden */
  42457. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42458. /**
  42459. * Gets the source code of the vertex shader associated with a specific webGL program
  42460. * @param program defines the program to use
  42461. * @returns a string containing the source code of the vertex shader associated with the program
  42462. */
  42463. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42464. /**
  42465. * Gets the source code of the fragment shader associated with a specific webGL program
  42466. * @param program defines the program to use
  42467. * @returns a string containing the source code of the fragment shader associated with the program
  42468. */
  42469. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42470. /**
  42471. * Sets a depth stencil texture from a render target to the according uniform.
  42472. * @param channel The texture channel
  42473. * @param uniform The uniform to set
  42474. * @param texture The render target texture containing the depth stencil texture to apply
  42475. * @param name The texture name
  42476. */
  42477. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42478. /**
  42479. * Sets a texture to the webGL context from a postprocess
  42480. * @param channel defines the channel to use
  42481. * @param postProcess defines the source postprocess
  42482. * @param name name of the channel
  42483. */
  42484. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42485. /**
  42486. * Binds the output of the passed in post process to the texture channel specified
  42487. * @param channel The channel the texture should be bound to
  42488. * @param postProcess The post process which's output should be bound
  42489. * @param name name of the channel
  42490. */
  42491. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42492. protected _rebuildBuffers(): void;
  42493. /** @hidden */
  42494. _renderFrame(): void;
  42495. _renderLoop(): void;
  42496. /** @hidden */
  42497. _renderViews(): boolean;
  42498. /**
  42499. * Toggle full screen mode
  42500. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42501. */
  42502. switchFullscreen(requestPointerLock: boolean): void;
  42503. /**
  42504. * Enters full screen mode
  42505. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42506. */
  42507. enterFullscreen(requestPointerLock: boolean): void;
  42508. /**
  42509. * Exits full screen mode
  42510. */
  42511. exitFullscreen(): void;
  42512. /**
  42513. * Enters Pointerlock mode
  42514. */
  42515. enterPointerlock(): void;
  42516. /**
  42517. * Exits Pointerlock mode
  42518. */
  42519. exitPointerlock(): void;
  42520. /**
  42521. * Begin a new frame
  42522. */
  42523. beginFrame(): void;
  42524. /**
  42525. * End the current frame
  42526. */
  42527. endFrame(): void;
  42528. /**
  42529. * Resize the view according to the canvas' size
  42530. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42531. */
  42532. resize(forceSetSize?: boolean): void;
  42533. /**
  42534. * Force a specific size of the canvas
  42535. * @param width defines the new canvas' width
  42536. * @param height defines the new canvas' height
  42537. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42538. * @returns true if the size was changed
  42539. */
  42540. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42541. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42542. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42543. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42544. _releaseTexture(texture: InternalTexture): void;
  42545. /**
  42546. * @hidden
  42547. * Rescales a texture
  42548. * @param source input texutre
  42549. * @param destination destination texture
  42550. * @param scene scene to use to render the resize
  42551. * @param internalFormat format to use when resizing
  42552. * @param onComplete callback to be called when resize has completed
  42553. */
  42554. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42555. /**
  42556. * Gets the current framerate
  42557. * @returns a number representing the framerate
  42558. */
  42559. getFps(): number;
  42560. /**
  42561. * Gets the time spent between current and previous frame
  42562. * @returns a number representing the delta time in ms
  42563. */
  42564. getDeltaTime(): number;
  42565. private _measureFps;
  42566. /** @hidden */
  42567. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42568. /**
  42569. * Updates the sample count of a render target texture
  42570. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42571. * @param texture defines the texture to update
  42572. * @param samples defines the sample count to set
  42573. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42574. */
  42575. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42576. /**
  42577. * Updates a depth texture Comparison Mode and Function.
  42578. * If the comparison Function is equal to 0, the mode will be set to none.
  42579. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42580. * @param texture The texture to set the comparison function for
  42581. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42582. */
  42583. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42584. /**
  42585. * Creates a webGL buffer to use with instanciation
  42586. * @param capacity defines the size of the buffer
  42587. * @returns the webGL buffer
  42588. */
  42589. createInstancesBuffer(capacity: number): DataBuffer;
  42590. /**
  42591. * Delete a webGL buffer used with instanciation
  42592. * @param buffer defines the webGL buffer to delete
  42593. */
  42594. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42595. private _clientWaitAsync;
  42596. /** @hidden */
  42597. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  42598. dispose(): void;
  42599. private _disableTouchAction;
  42600. /**
  42601. * Display the loading screen
  42602. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42603. */
  42604. displayLoadingUI(): void;
  42605. /**
  42606. * Hide the loading screen
  42607. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42608. */
  42609. hideLoadingUI(): void;
  42610. /**
  42611. * Gets the current loading screen object
  42612. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42613. */
  42614. get loadingScreen(): ILoadingScreen;
  42615. /**
  42616. * Sets the current loading screen object
  42617. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42618. */
  42619. set loadingScreen(loadingScreen: ILoadingScreen);
  42620. /**
  42621. * Sets the current loading screen text
  42622. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42623. */
  42624. set loadingUIText(text: string);
  42625. /**
  42626. * Sets the current loading screen background color
  42627. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42628. */
  42629. set loadingUIBackgroundColor(color: string);
  42630. /** Pointerlock and fullscreen */
  42631. /**
  42632. * Ask the browser to promote the current element to pointerlock mode
  42633. * @param element defines the DOM element to promote
  42634. */
  42635. static _RequestPointerlock(element: HTMLElement): void;
  42636. /**
  42637. * Asks the browser to exit pointerlock mode
  42638. */
  42639. static _ExitPointerlock(): void;
  42640. /**
  42641. * Ask the browser to promote the current element to fullscreen rendering mode
  42642. * @param element defines the DOM element to promote
  42643. */
  42644. static _RequestFullscreen(element: HTMLElement): void;
  42645. /**
  42646. * Asks the browser to exit fullscreen mode
  42647. */
  42648. static _ExitFullscreen(): void;
  42649. }
  42650. }
  42651. declare module BABYLON {
  42652. /**
  42653. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42654. * during the life time of the application.
  42655. */
  42656. export class EngineStore {
  42657. /** Gets the list of created engines */
  42658. static Instances: Engine[];
  42659. /** @hidden */
  42660. static _LastCreatedScene: Nullable<Scene>;
  42661. /**
  42662. * Gets the latest created engine
  42663. */
  42664. static get LastCreatedEngine(): Nullable<Engine>;
  42665. /**
  42666. * Gets the latest created scene
  42667. */
  42668. static get LastCreatedScene(): Nullable<Scene>;
  42669. /**
  42670. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42671. * @ignorenaming
  42672. */
  42673. static UseFallbackTexture: boolean;
  42674. /**
  42675. * Texture content used if a texture cannot loaded
  42676. * @ignorenaming
  42677. */
  42678. static FallbackTexture: string;
  42679. }
  42680. }
  42681. declare module BABYLON {
  42682. /**
  42683. * Helper class that provides a small promise polyfill
  42684. */
  42685. export class PromisePolyfill {
  42686. /**
  42687. * Static function used to check if the polyfill is required
  42688. * If this is the case then the function will inject the polyfill to window.Promise
  42689. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42690. */
  42691. static Apply(force?: boolean): void;
  42692. }
  42693. }
  42694. declare module BABYLON {
  42695. /**
  42696. * Interface for screenshot methods with describe argument called `size` as object with options
  42697. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42698. */
  42699. export interface IScreenshotSize {
  42700. /**
  42701. * number in pixels for canvas height
  42702. */
  42703. height?: number;
  42704. /**
  42705. * multiplier allowing render at a higher or lower resolution
  42706. * If value is defined then height and width will be ignored and taken from camera
  42707. */
  42708. precision?: number;
  42709. /**
  42710. * number in pixels for canvas width
  42711. */
  42712. width?: number;
  42713. }
  42714. }
  42715. declare module BABYLON {
  42716. interface IColor4Like {
  42717. r: float;
  42718. g: float;
  42719. b: float;
  42720. a: float;
  42721. }
  42722. /**
  42723. * Class containing a set of static utilities functions
  42724. */
  42725. export class Tools {
  42726. /**
  42727. * Gets or sets the base URL to use to load assets
  42728. */
  42729. static get BaseUrl(): string;
  42730. static set BaseUrl(value: string);
  42731. /**
  42732. * Enable/Disable Custom HTTP Request Headers globally.
  42733. * default = false
  42734. * @see CustomRequestHeaders
  42735. */
  42736. static UseCustomRequestHeaders: boolean;
  42737. /**
  42738. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42739. * i.e. when loading files, where the server/service expects an Authorization header
  42740. */
  42741. static CustomRequestHeaders: {
  42742. [key: string]: string;
  42743. };
  42744. /**
  42745. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42746. */
  42747. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42748. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42749. /**
  42750. * Default behaviour for cors in the application.
  42751. * It can be a string if the expected behavior is identical in the entire app.
  42752. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42753. */
  42754. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42755. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42756. /**
  42757. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42758. * @ignorenaming
  42759. */
  42760. static get UseFallbackTexture(): boolean;
  42761. static set UseFallbackTexture(value: boolean);
  42762. /**
  42763. * Use this object to register external classes like custom textures or material
  42764. * to allow the laoders to instantiate them
  42765. */
  42766. static get RegisteredExternalClasses(): {
  42767. [key: string]: Object;
  42768. };
  42769. static set RegisteredExternalClasses(classes: {
  42770. [key: string]: Object;
  42771. });
  42772. /**
  42773. * Texture content used if a texture cannot loaded
  42774. * @ignorenaming
  42775. */
  42776. static get fallbackTexture(): string;
  42777. static set fallbackTexture(value: string);
  42778. /**
  42779. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42780. * @param u defines the coordinate on X axis
  42781. * @param v defines the coordinate on Y axis
  42782. * @param width defines the width of the source data
  42783. * @param height defines the height of the source data
  42784. * @param pixels defines the source byte array
  42785. * @param color defines the output color
  42786. */
  42787. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42788. /**
  42789. * Interpolates between a and b via alpha
  42790. * @param a The lower value (returned when alpha = 0)
  42791. * @param b The upper value (returned when alpha = 1)
  42792. * @param alpha The interpolation-factor
  42793. * @return The mixed value
  42794. */
  42795. static Mix(a: number, b: number, alpha: number): number;
  42796. /**
  42797. * Tries to instantiate a new object from a given class name
  42798. * @param className defines the class name to instantiate
  42799. * @returns the new object or null if the system was not able to do the instantiation
  42800. */
  42801. static Instantiate(className: string): any;
  42802. /**
  42803. * Provides a slice function that will work even on IE
  42804. * @param data defines the array to slice
  42805. * @param start defines the start of the data (optional)
  42806. * @param end defines the end of the data (optional)
  42807. * @returns the new sliced array
  42808. */
  42809. static Slice<T>(data: T, start?: number, end?: number): T;
  42810. /**
  42811. * Provides a slice function that will work even on IE
  42812. * The difference between this and Slice is that this will force-convert to array
  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 SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  42819. /**
  42820. * Polyfill for setImmediate
  42821. * @param action defines the action to execute after the current execution block
  42822. */
  42823. static SetImmediate(action: () => void): void;
  42824. /**
  42825. * Function indicating if a number is an exponent of 2
  42826. * @param value defines the value to test
  42827. * @returns true if the value is an exponent of 2
  42828. */
  42829. static IsExponentOfTwo(value: number): boolean;
  42830. private static _tmpFloatArray;
  42831. /**
  42832. * Returns the nearest 32-bit single precision float representation of a Number
  42833. * @param value A Number. If the parameter is of a different type, it will get converted
  42834. * to a number or to NaN if it cannot be converted
  42835. * @returns number
  42836. */
  42837. static FloatRound(value: number): number;
  42838. /**
  42839. * Extracts the filename from a path
  42840. * @param path defines the path to use
  42841. * @returns the filename
  42842. */
  42843. static GetFilename(path: string): string;
  42844. /**
  42845. * Extracts the "folder" part of a path (everything before the filename).
  42846. * @param uri The URI to extract the info from
  42847. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42848. * @returns The "folder" part of the path
  42849. */
  42850. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42851. /**
  42852. * Extracts text content from a DOM element hierarchy
  42853. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42854. */
  42855. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42856. /**
  42857. * Convert an angle in radians to degrees
  42858. * @param angle defines the angle to convert
  42859. * @returns the angle in degrees
  42860. */
  42861. static ToDegrees(angle: number): number;
  42862. /**
  42863. * Convert an angle in degrees to radians
  42864. * @param angle defines the angle to convert
  42865. * @returns the angle in radians
  42866. */
  42867. static ToRadians(angle: number): number;
  42868. /**
  42869. * Returns an array if obj is not an array
  42870. * @param obj defines the object to evaluate as an array
  42871. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42872. * @returns either obj directly if obj is an array or a new array containing obj
  42873. */
  42874. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42875. /**
  42876. * Gets the pointer prefix to use
  42877. * @param engine defines the engine we are finding the prefix for
  42878. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42879. */
  42880. static GetPointerPrefix(engine: Engine): string;
  42881. /**
  42882. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42883. * @param url define the url we are trying
  42884. * @param element define the dom element where to configure the cors policy
  42885. */
  42886. static SetCorsBehavior(url: string | string[], element: {
  42887. crossOrigin: string | null;
  42888. }): void;
  42889. /**
  42890. * Removes unwanted characters from an url
  42891. * @param url defines the url to clean
  42892. * @returns the cleaned url
  42893. */
  42894. static CleanUrl(url: string): string;
  42895. /**
  42896. * Gets or sets a function used to pre-process url before using them to load assets
  42897. */
  42898. static get PreprocessUrl(): (url: string) => string;
  42899. static set PreprocessUrl(processor: (url: string) => string);
  42900. /**
  42901. * Loads an image as an HTMLImageElement.
  42902. * @param input url string, ArrayBuffer, or Blob to load
  42903. * @param onLoad callback called when the image successfully loads
  42904. * @param onError callback called when the image fails to load
  42905. * @param offlineProvider offline provider for caching
  42906. * @param mimeType optional mime type
  42907. * @returns the HTMLImageElement of the loaded image
  42908. */
  42909. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42910. /**
  42911. * Loads a file from a url
  42912. * @param url url string, ArrayBuffer, or Blob to load
  42913. * @param onSuccess callback called when the file successfully loads
  42914. * @param onProgress callback called while file is loading (if the server supports this mode)
  42915. * @param offlineProvider defines the offline provider for caching
  42916. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42917. * @param onError callback called when the file fails to load
  42918. * @returns a file request object
  42919. */
  42920. 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;
  42921. /**
  42922. * Loads a file from a url
  42923. * @param url the file url to load
  42924. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42925. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42926. */
  42927. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42928. /**
  42929. * Load a script (identified by an url). When the url returns, the
  42930. * content of this file is added into a new script element, attached to the DOM (body element)
  42931. * @param scriptUrl defines the url of the script to laod
  42932. * @param onSuccess defines the callback called when the script is loaded
  42933. * @param onError defines the callback to call if an error occurs
  42934. * @param scriptId defines the id of the script element
  42935. */
  42936. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42937. /**
  42938. * Load an asynchronous 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 scriptId defines the id of the script element
  42942. * @returns a promise request object
  42943. */
  42944. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42945. /**
  42946. * Loads a file from a blob
  42947. * @param fileToLoad defines the blob to use
  42948. * @param callback defines the callback to call when data is loaded
  42949. * @param progressCallback defines the callback to call during loading process
  42950. * @returns a file request object
  42951. */
  42952. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  42953. /**
  42954. * Reads a file from a File object
  42955. * @param file defines the file to load
  42956. * @param onSuccess defines the callback to call when data is loaded
  42957. * @param onProgress defines the callback to call during loading process
  42958. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42959. * @param onError defines the callback to call when an error occurs
  42960. * @returns a file request object
  42961. */
  42962. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42963. /**
  42964. * Creates a data url from a given string content
  42965. * @param content defines the content to convert
  42966. * @returns the new data url link
  42967. */
  42968. static FileAsURL(content: string): string;
  42969. /**
  42970. * Format the given number to a specific decimal format
  42971. * @param value defines the number to format
  42972. * @param decimals defines the number of decimals to use
  42973. * @returns the formatted string
  42974. */
  42975. static Format(value: number, decimals?: number): string;
  42976. /**
  42977. * Tries to copy an object by duplicating every property
  42978. * @param source defines the source object
  42979. * @param destination defines the target object
  42980. * @param doNotCopyList defines a list of properties to avoid
  42981. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  42982. */
  42983. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  42984. /**
  42985. * Gets a boolean indicating if the given object has no own property
  42986. * @param obj defines the object to test
  42987. * @returns true if object has no own property
  42988. */
  42989. static IsEmpty(obj: any): boolean;
  42990. /**
  42991. * Function used to register events at window level
  42992. * @param windowElement defines the Window object to use
  42993. * @param events defines the events to register
  42994. */
  42995. static RegisterTopRootEvents(windowElement: Window, events: {
  42996. name: string;
  42997. handler: Nullable<(e: FocusEvent) => any>;
  42998. }[]): void;
  42999. /**
  43000. * Function used to unregister events from window level
  43001. * @param windowElement defines the Window object to use
  43002. * @param events defines the events to unregister
  43003. */
  43004. static UnregisterTopRootEvents(windowElement: Window, events: {
  43005. name: string;
  43006. handler: Nullable<(e: FocusEvent) => any>;
  43007. }[]): void;
  43008. /**
  43009. * @ignore
  43010. */
  43011. static _ScreenshotCanvas: HTMLCanvasElement;
  43012. /**
  43013. * Dumps the current bound framebuffer
  43014. * @param width defines the rendering width
  43015. * @param height defines the rendering height
  43016. * @param engine defines the hosting engine
  43017. * @param successCallback defines the callback triggered once the data are available
  43018. * @param mimeType defines the mime type of the result
  43019. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43020. * @return a void promise
  43021. */
  43022. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43023. /**
  43024. * Dumps an array buffer
  43025. * @param width defines the rendering width
  43026. * @param height defines the rendering height
  43027. * @param data the data array
  43028. * @param successCallback defines the callback triggered once the data are available
  43029. * @param mimeType defines the mime type of the result
  43030. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43031. * @param invertY true to invert the picture in the Y dimension
  43032. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43033. */
  43034. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43035. /**
  43036. * Dumps an array buffer
  43037. * @param width defines the rendering width
  43038. * @param height defines the rendering height
  43039. * @param data the data array
  43040. * @param successCallback defines the callback triggered once the data are available
  43041. * @param mimeType defines the mime type of the result
  43042. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43043. * @param invertY true to invert the picture in the Y dimension
  43044. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43045. * @return a promise that resolve to the final data
  43046. */
  43047. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43048. /**
  43049. * Converts the canvas data to blob.
  43050. * This acts as a polyfill for browsers not supporting the to blob function.
  43051. * @param canvas Defines the canvas to extract the data from
  43052. * @param successCallback Defines the callback triggered once the data are available
  43053. * @param mimeType Defines the mime type of the result
  43054. */
  43055. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43056. /**
  43057. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43058. * @param successCallback defines the callback triggered once the data are available
  43059. * @param mimeType defines the mime type of the result
  43060. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43061. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43062. */
  43063. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43064. /**
  43065. * Downloads a blob in the browser
  43066. * @param blob defines the blob to download
  43067. * @param fileName defines the name of the downloaded file
  43068. */
  43069. static Download(blob: Blob, fileName: string): void;
  43070. /**
  43071. * Will return the right value of the noPreventDefault variable
  43072. * Needed to keep backwards compatibility to the old API.
  43073. *
  43074. * @param args arguments passed to the attachControl function
  43075. * @returns the correct value for noPreventDefault
  43076. */
  43077. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43078. /**
  43079. * Captures a screenshot of the current rendering
  43080. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43081. * @param engine defines the rendering engine
  43082. * @param camera defines the source camera
  43083. * @param size This parameter can be set to a single number or to an object with the
  43084. * following (optional) properties: precision, width, height. If a single number is passed,
  43085. * it will be used for both width and height. If an object is passed, the screenshot size
  43086. * will be derived from the parameters. The precision property is a multiplier allowing
  43087. * rendering at a higher or lower resolution
  43088. * @param successCallback defines the callback receives a single parameter which contains the
  43089. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43090. * src parameter of an <img> to display it
  43091. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43092. * Check your browser for supported MIME types
  43093. */
  43094. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43095. /**
  43096. * Captures a screenshot of the current rendering
  43097. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43098. * @param engine defines the rendering engine
  43099. * @param camera defines the source camera
  43100. * @param size This parameter can be set to a single number or to an object with the
  43101. * following (optional) properties: precision, width, height. If a single number is passed,
  43102. * it will be used for both width and height. If an object is passed, the screenshot size
  43103. * will be derived from the parameters. The precision property is a multiplier allowing
  43104. * rendering at a higher or lower resolution
  43105. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43106. * Check your browser for supported MIME types
  43107. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43108. * to the src parameter of an <img> to display it
  43109. */
  43110. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43111. /**
  43112. * Generates an image screenshot from the specified camera.
  43113. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43114. * @param engine The engine to use for rendering
  43115. * @param camera The camera to use for rendering
  43116. * @param size This parameter can be set to a single number or to an object with the
  43117. * following (optional) properties: precision, width, height. If a single number is passed,
  43118. * it will be used for both width and height. If an object is passed, the screenshot size
  43119. * will be derived from the parameters. The precision property is a multiplier allowing
  43120. * rendering at a higher or lower resolution
  43121. * @param successCallback The callback receives a single parameter which contains the
  43122. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43123. * src parameter of an <img> to display it
  43124. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43125. * Check your browser for supported MIME types
  43126. * @param samples Texture samples (default: 1)
  43127. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43128. * @param fileName A name for for the downloaded file.
  43129. */
  43130. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43131. /**
  43132. * Generates an image screenshot from the specified camera.
  43133. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43134. * @param engine The engine to use for rendering
  43135. * @param camera The camera to use for rendering
  43136. * @param size This parameter can be set to a single number or to an object with the
  43137. * following (optional) properties: precision, width, height. If a single number is passed,
  43138. * it will be used for both width and height. If an object is passed, the screenshot size
  43139. * will be derived from the parameters. The precision property is a multiplier allowing
  43140. * rendering at a higher or lower resolution
  43141. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43142. * Check your browser for supported MIME types
  43143. * @param samples Texture samples (default: 1)
  43144. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43145. * @param fileName A name for for the downloaded file.
  43146. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43147. * to the src parameter of an <img> to display it
  43148. */
  43149. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43150. /**
  43151. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43152. * Be aware Math.random() could cause collisions, but:
  43153. * "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"
  43154. * @returns a pseudo random id
  43155. */
  43156. static RandomId(): string;
  43157. /**
  43158. * Test if the given uri is a base64 string
  43159. * @param uri The uri to test
  43160. * @return True if the uri is a base64 string or false otherwise
  43161. */
  43162. static IsBase64(uri: string): boolean;
  43163. /**
  43164. * Decode the given base64 uri.
  43165. * @param uri The uri to decode
  43166. * @return The decoded base64 data.
  43167. */
  43168. static DecodeBase64(uri: string): ArrayBuffer;
  43169. /**
  43170. * Gets the absolute url.
  43171. * @param url the input url
  43172. * @return the absolute url
  43173. */
  43174. static GetAbsoluteUrl(url: string): string;
  43175. /**
  43176. * No log
  43177. */
  43178. static readonly NoneLogLevel: number;
  43179. /**
  43180. * Only message logs
  43181. */
  43182. static readonly MessageLogLevel: number;
  43183. /**
  43184. * Only warning logs
  43185. */
  43186. static readonly WarningLogLevel: number;
  43187. /**
  43188. * Only error logs
  43189. */
  43190. static readonly ErrorLogLevel: number;
  43191. /**
  43192. * All logs
  43193. */
  43194. static readonly AllLogLevel: number;
  43195. /**
  43196. * Gets a value indicating the number of loading errors
  43197. * @ignorenaming
  43198. */
  43199. static get errorsCount(): number;
  43200. /**
  43201. * Callback called when a new log is added
  43202. */
  43203. static OnNewCacheEntry: (entry: string) => void;
  43204. /**
  43205. * Log a message to the console
  43206. * @param message defines the message to log
  43207. */
  43208. static Log(message: string): void;
  43209. /**
  43210. * Write a warning message to the console
  43211. * @param message defines the message to log
  43212. */
  43213. static Warn(message: string): void;
  43214. /**
  43215. * Write an error message to the console
  43216. * @param message defines the message to log
  43217. */
  43218. static Error(message: string): void;
  43219. /**
  43220. * Gets current log cache (list of logs)
  43221. */
  43222. static get LogCache(): string;
  43223. /**
  43224. * Clears the log cache
  43225. */
  43226. static ClearLogCache(): void;
  43227. /**
  43228. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43229. */
  43230. static set LogLevels(level: number);
  43231. /**
  43232. * Checks if the window object exists
  43233. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43234. */
  43235. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43236. /**
  43237. * No performance log
  43238. */
  43239. static readonly PerformanceNoneLogLevel: number;
  43240. /**
  43241. * Use user marks to log performance
  43242. */
  43243. static readonly PerformanceUserMarkLogLevel: number;
  43244. /**
  43245. * Log performance to the console
  43246. */
  43247. static readonly PerformanceConsoleLogLevel: number;
  43248. private static _performance;
  43249. /**
  43250. * Sets the current performance log level
  43251. */
  43252. static set PerformanceLogLevel(level: number);
  43253. private static _StartPerformanceCounterDisabled;
  43254. private static _EndPerformanceCounterDisabled;
  43255. private static _StartUserMark;
  43256. private static _EndUserMark;
  43257. private static _StartPerformanceConsole;
  43258. private static _EndPerformanceConsole;
  43259. /**
  43260. * Starts a performance counter
  43261. */
  43262. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43263. /**
  43264. * Ends a specific performance coutner
  43265. */
  43266. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43267. /**
  43268. * Gets either window.performance.now() if supported or Date.now() else
  43269. */
  43270. static get Now(): number;
  43271. /**
  43272. * This method will return the name of the class used to create the instance of the given object.
  43273. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43274. * @param object the object to get the class name from
  43275. * @param isType defines if the object is actually a type
  43276. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43277. */
  43278. static GetClassName(object: any, isType?: boolean): string;
  43279. /**
  43280. * Gets the first element of an array satisfying a given predicate
  43281. * @param array defines the array to browse
  43282. * @param predicate defines the predicate to use
  43283. * @returns null if not found or the element
  43284. */
  43285. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43286. /**
  43287. * This method will return the name of the full name of the class, including its owning module (if any).
  43288. * 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).
  43289. * @param object the object to get the class name from
  43290. * @param isType defines if the object is actually a type
  43291. * @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.
  43292. * @ignorenaming
  43293. */
  43294. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43295. /**
  43296. * Returns a promise that resolves after the given amount of time.
  43297. * @param delay Number of milliseconds to delay
  43298. * @returns Promise that resolves after the given amount of time
  43299. */
  43300. static DelayAsync(delay: number): Promise<void>;
  43301. /**
  43302. * Utility function to detect if the current user agent is Safari
  43303. * @returns whether or not the current user agent is safari
  43304. */
  43305. static IsSafari(): boolean;
  43306. }
  43307. /**
  43308. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43309. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43310. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43311. * @param name The name of the class, case should be preserved
  43312. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43313. */
  43314. export function className(name: string, module?: string): (target: Object) => void;
  43315. /**
  43316. * An implementation of a loop for asynchronous functions.
  43317. */
  43318. export class AsyncLoop {
  43319. /**
  43320. * Defines the number of iterations for the loop
  43321. */
  43322. iterations: number;
  43323. /**
  43324. * Defines the current index of the loop.
  43325. */
  43326. index: number;
  43327. private _done;
  43328. private _fn;
  43329. private _successCallback;
  43330. /**
  43331. * Constructor.
  43332. * @param iterations the number of iterations.
  43333. * @param func the function to run each iteration
  43334. * @param successCallback the callback that will be called upon succesful execution
  43335. * @param offset starting offset.
  43336. */
  43337. constructor(
  43338. /**
  43339. * Defines the number of iterations for the loop
  43340. */
  43341. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43342. /**
  43343. * Execute the next iteration. Must be called after the last iteration was finished.
  43344. */
  43345. executeNext(): void;
  43346. /**
  43347. * Break the loop and run the success callback.
  43348. */
  43349. breakLoop(): void;
  43350. /**
  43351. * Create and run an async loop.
  43352. * @param iterations the number of iterations.
  43353. * @param fn the function to run each iteration
  43354. * @param successCallback the callback that will be called upon succesful execution
  43355. * @param offset starting offset.
  43356. * @returns the created async loop object
  43357. */
  43358. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43359. /**
  43360. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43361. * @param iterations total number of iterations
  43362. * @param syncedIterations number of synchronous iterations in each async iteration.
  43363. * @param fn the function to call each iteration.
  43364. * @param callback a success call back that will be called when iterating stops.
  43365. * @param breakFunction a break condition (optional)
  43366. * @param timeout timeout settings for the setTimeout function. default - 0.
  43367. * @returns the created async loop object
  43368. */
  43369. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43370. }
  43371. }
  43372. declare module BABYLON {
  43373. /**
  43374. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43375. * The underlying implementation relies on an associative array to ensure the best performances.
  43376. * The value can be anything including 'null' but except 'undefined'
  43377. */
  43378. export class StringDictionary<T> {
  43379. /**
  43380. * This will clear this dictionary and copy the content from the 'source' one.
  43381. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43382. * @param source the dictionary to take the content from and copy to this dictionary
  43383. */
  43384. copyFrom(source: StringDictionary<T>): void;
  43385. /**
  43386. * Get a value based from its key
  43387. * @param key the given key to get the matching value from
  43388. * @return the value if found, otherwise undefined is returned
  43389. */
  43390. get(key: string): T | undefined;
  43391. /**
  43392. * Get a value from its key or add it if it doesn't exist.
  43393. * This method will ensure you that a given key/data will be present in the dictionary.
  43394. * @param key the given key to get the matching value from
  43395. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43396. * The factory will only be invoked if there's no data for the given key.
  43397. * @return the value corresponding to the key.
  43398. */
  43399. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43400. /**
  43401. * Get a value from its key if present in the dictionary otherwise add it
  43402. * @param key the key to get the value from
  43403. * @param val if there's no such key/value pair in the dictionary add it with this value
  43404. * @return the value corresponding to the key
  43405. */
  43406. getOrAdd(key: string, val: T): T;
  43407. /**
  43408. * Check if there's a given key in the dictionary
  43409. * @param key the key to check for
  43410. * @return true if the key is present, false otherwise
  43411. */
  43412. contains(key: string): boolean;
  43413. /**
  43414. * Add a new key and its corresponding value
  43415. * @param key the key to add
  43416. * @param value the value corresponding to the key
  43417. * @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
  43418. */
  43419. add(key: string, value: T): boolean;
  43420. /**
  43421. * Update a specific value associated to a key
  43422. * @param key defines the key to use
  43423. * @param value defines the value to store
  43424. * @returns true if the value was updated (or false if the key was not found)
  43425. */
  43426. set(key: string, value: T): boolean;
  43427. /**
  43428. * Get the element of the given key and remove it from the dictionary
  43429. * @param key defines the key to search
  43430. * @returns the value associated with the key or null if not found
  43431. */
  43432. getAndRemove(key: string): Nullable<T>;
  43433. /**
  43434. * Remove a key/value from the dictionary.
  43435. * @param key the key to remove
  43436. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43437. */
  43438. remove(key: string): boolean;
  43439. /**
  43440. * Clear the whole content of the dictionary
  43441. */
  43442. clear(): void;
  43443. /**
  43444. * Gets the current count
  43445. */
  43446. get count(): number;
  43447. /**
  43448. * Execute a callback on each key/val of the dictionary.
  43449. * Note that you can remove any element in this dictionary in the callback implementation
  43450. * @param callback the callback to execute on a given key/value pair
  43451. */
  43452. forEach(callback: (key: string, val: T) => void): void;
  43453. /**
  43454. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43455. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43456. * Note that you can remove any element in this dictionary in the callback implementation
  43457. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43458. * @returns the first item
  43459. */
  43460. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43461. private _count;
  43462. private _data;
  43463. }
  43464. }
  43465. declare module BABYLON {
  43466. /** @hidden */
  43467. export interface ICollisionCoordinator {
  43468. createCollider(): Collider;
  43469. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43470. init(scene: Scene): void;
  43471. }
  43472. /** @hidden */
  43473. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43474. private _scene;
  43475. private _scaledPosition;
  43476. private _scaledVelocity;
  43477. private _finalPosition;
  43478. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43479. createCollider(): Collider;
  43480. init(scene: Scene): void;
  43481. private _collideWithWorld;
  43482. }
  43483. }
  43484. declare module BABYLON {
  43485. /**
  43486. * Class used to manage all inputs for the scene.
  43487. */
  43488. export class InputManager {
  43489. /** The distance in pixel that you have to move to prevent some events */
  43490. static DragMovementThreshold: number;
  43491. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43492. static LongPressDelay: number;
  43493. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43494. static DoubleClickDelay: number;
  43495. /** If you need to check double click without raising a single click at first click, enable this flag */
  43496. static ExclusiveDoubleClickMode: boolean;
  43497. /** 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. */
  43498. private _alreadyAttached;
  43499. private _alreadyAttachedTo;
  43500. private _wheelEventName;
  43501. private _onPointerMove;
  43502. private _onPointerDown;
  43503. private _onPointerUp;
  43504. private _initClickEvent;
  43505. private _initActionManager;
  43506. private _delayedSimpleClick;
  43507. private _delayedSimpleClickTimeout;
  43508. private _previousDelayedSimpleClickTimeout;
  43509. private _meshPickProceed;
  43510. private _previousButtonPressed;
  43511. private _currentPickResult;
  43512. private _previousPickResult;
  43513. private _totalPointersPressed;
  43514. private _doubleClickOccured;
  43515. private _pointerOverMesh;
  43516. private _pickedDownMesh;
  43517. private _pickedUpMesh;
  43518. private _pointerX;
  43519. private _pointerY;
  43520. private _unTranslatedPointerX;
  43521. private _unTranslatedPointerY;
  43522. private _startingPointerPosition;
  43523. private _previousStartingPointerPosition;
  43524. private _startingPointerTime;
  43525. private _previousStartingPointerTime;
  43526. private _pointerCaptures;
  43527. private _meshUnderPointerId;
  43528. private _onKeyDown;
  43529. private _onKeyUp;
  43530. private _keyboardIsAttached;
  43531. private _onCanvasFocusObserver;
  43532. private _onCanvasBlurObserver;
  43533. private _scene;
  43534. /**
  43535. * Creates a new InputManager
  43536. * @param scene defines the hosting scene
  43537. */
  43538. constructor(scene: Scene);
  43539. /**
  43540. * Gets the mesh that is currently under the pointer
  43541. */
  43542. get meshUnderPointer(): Nullable<AbstractMesh>;
  43543. /**
  43544. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43545. * @param pointerId the pointer id to use
  43546. * @returns The mesh under this pointer id or null if not found
  43547. */
  43548. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43549. /**
  43550. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43551. */
  43552. get unTranslatedPointer(): Vector2;
  43553. /**
  43554. * Gets or sets the current on-screen X position of the pointer
  43555. */
  43556. get pointerX(): number;
  43557. set pointerX(value: number);
  43558. /**
  43559. * Gets or sets the current on-screen Y position of the pointer
  43560. */
  43561. get pointerY(): number;
  43562. set pointerY(value: number);
  43563. private _updatePointerPosition;
  43564. private _processPointerMove;
  43565. private _setRayOnPointerInfo;
  43566. private _checkPrePointerObservable;
  43567. /**
  43568. * Use this method to simulate a pointer move on a mesh
  43569. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43570. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43571. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43572. */
  43573. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43574. /**
  43575. * Use this method to simulate a pointer down on a mesh
  43576. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43577. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43578. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43579. */
  43580. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43581. private _processPointerDown;
  43582. /** @hidden */
  43583. _isPointerSwiping(): boolean;
  43584. /**
  43585. * Use this method to simulate a pointer up on a mesh
  43586. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43587. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43588. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43589. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43590. */
  43591. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43592. private _processPointerUp;
  43593. /**
  43594. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43595. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43596. * @returns true if the pointer was captured
  43597. */
  43598. isPointerCaptured(pointerId?: number): boolean;
  43599. /**
  43600. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43601. * @param attachUp defines if you want to attach events to pointerup
  43602. * @param attachDown defines if you want to attach events to pointerdown
  43603. * @param attachMove defines if you want to attach events to pointermove
  43604. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43605. */
  43606. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43607. /**
  43608. * Detaches all event handlers
  43609. */
  43610. detachControl(): void;
  43611. /**
  43612. * Force the value of meshUnderPointer
  43613. * @param mesh defines the mesh to use
  43614. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43615. */
  43616. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43617. /**
  43618. * Gets the mesh under the pointer
  43619. * @returns a Mesh or null if no mesh is under the pointer
  43620. */
  43621. getPointerOverMesh(): Nullable<AbstractMesh>;
  43622. }
  43623. }
  43624. declare module BABYLON {
  43625. /**
  43626. * This class defines the direct association between an animation and a target
  43627. */
  43628. export class TargetedAnimation {
  43629. /**
  43630. * Animation to perform
  43631. */
  43632. animation: Animation;
  43633. /**
  43634. * Target to animate
  43635. */
  43636. target: any;
  43637. /**
  43638. * Returns the string "TargetedAnimation"
  43639. * @returns "TargetedAnimation"
  43640. */
  43641. getClassName(): string;
  43642. /**
  43643. * Serialize the object
  43644. * @returns the JSON object representing the current entity
  43645. */
  43646. serialize(): any;
  43647. }
  43648. /**
  43649. * Use this class to create coordinated animations on multiple targets
  43650. */
  43651. export class AnimationGroup implements IDisposable {
  43652. /** The name of the animation group */
  43653. name: string;
  43654. private _scene;
  43655. private _targetedAnimations;
  43656. private _animatables;
  43657. private _from;
  43658. private _to;
  43659. private _isStarted;
  43660. private _isPaused;
  43661. private _speedRatio;
  43662. private _loopAnimation;
  43663. private _isAdditive;
  43664. /**
  43665. * Gets or sets the unique id of the node
  43666. */
  43667. uniqueId: number;
  43668. /**
  43669. * This observable will notify when one animation have ended
  43670. */
  43671. onAnimationEndObservable: Observable<TargetedAnimation>;
  43672. /**
  43673. * Observer raised when one animation loops
  43674. */
  43675. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43676. /**
  43677. * Observer raised when all animations have looped
  43678. */
  43679. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43680. /**
  43681. * This observable will notify when all animations have ended.
  43682. */
  43683. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43684. /**
  43685. * This observable will notify when all animations have paused.
  43686. */
  43687. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43688. /**
  43689. * This observable will notify when all animations are playing.
  43690. */
  43691. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43692. /**
  43693. * Gets the first frame
  43694. */
  43695. get from(): number;
  43696. /**
  43697. * Gets the last frame
  43698. */
  43699. get to(): number;
  43700. /**
  43701. * Define if the animations are started
  43702. */
  43703. get isStarted(): boolean;
  43704. /**
  43705. * Gets a value indicating that the current group is playing
  43706. */
  43707. get isPlaying(): boolean;
  43708. /**
  43709. * Gets or sets the speed ratio to use for all animations
  43710. */
  43711. get speedRatio(): number;
  43712. /**
  43713. * Gets or sets the speed ratio to use for all animations
  43714. */
  43715. set speedRatio(value: number);
  43716. /**
  43717. * Gets or sets if all animations should loop or not
  43718. */
  43719. get loopAnimation(): boolean;
  43720. set loopAnimation(value: boolean);
  43721. /**
  43722. * Gets or sets if all animations should be evaluated additively
  43723. */
  43724. get isAdditive(): boolean;
  43725. set isAdditive(value: boolean);
  43726. /**
  43727. * Gets the targeted animations for this animation group
  43728. */
  43729. get targetedAnimations(): Array<TargetedAnimation>;
  43730. /**
  43731. * returning the list of animatables controlled by this animation group.
  43732. */
  43733. get animatables(): Array<Animatable>;
  43734. /**
  43735. * Gets the list of target animations
  43736. */
  43737. get children(): TargetedAnimation[];
  43738. /**
  43739. * Instantiates a new Animation Group.
  43740. * This helps managing several animations at once.
  43741. * @see https://doc.babylonjs.com/how_to/group
  43742. * @param name Defines the name of the group
  43743. * @param scene Defines the scene the group belongs to
  43744. */
  43745. constructor(
  43746. /** The name of the animation group */
  43747. name: string, scene?: Nullable<Scene>);
  43748. /**
  43749. * Add an animation (with its target) in the group
  43750. * @param animation defines the animation we want to add
  43751. * @param target defines the target of the animation
  43752. * @returns the TargetedAnimation object
  43753. */
  43754. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43755. /**
  43756. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43757. * It can add constant keys at begin or end
  43758. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43759. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43760. * @returns the animation group
  43761. */
  43762. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43763. private _animationLoopCount;
  43764. private _animationLoopFlags;
  43765. private _processLoop;
  43766. /**
  43767. * Start all animations on given targets
  43768. * @param loop defines if animations must loop
  43769. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43770. * @param from defines the from key (optional)
  43771. * @param to defines the to key (optional)
  43772. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43773. * @returns the current animation group
  43774. */
  43775. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43776. /**
  43777. * Pause all animations
  43778. * @returns the animation group
  43779. */
  43780. pause(): AnimationGroup;
  43781. /**
  43782. * Play all animations to initial state
  43783. * This function will start() the animations if they were not started or will restart() them if they were paused
  43784. * @param loop defines if animations must loop
  43785. * @returns the animation group
  43786. */
  43787. play(loop?: boolean): AnimationGroup;
  43788. /**
  43789. * Reset all animations to initial state
  43790. * @returns the animation group
  43791. */
  43792. reset(): AnimationGroup;
  43793. /**
  43794. * Restart animations from key 0
  43795. * @returns the animation group
  43796. */
  43797. restart(): AnimationGroup;
  43798. /**
  43799. * Stop all animations
  43800. * @returns the animation group
  43801. */
  43802. stop(): AnimationGroup;
  43803. /**
  43804. * Set animation weight for all animatables
  43805. * @param weight defines the weight to use
  43806. * @return the animationGroup
  43807. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43808. */
  43809. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43810. /**
  43811. * Synchronize and normalize all animatables with a source animatable
  43812. * @param root defines the root animatable to synchronize with
  43813. * @return the animationGroup
  43814. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43815. */
  43816. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43817. /**
  43818. * Goes to a specific frame in this animation group
  43819. * @param frame the frame number to go to
  43820. * @return the animationGroup
  43821. */
  43822. goToFrame(frame: number): AnimationGroup;
  43823. /**
  43824. * Dispose all associated resources
  43825. */
  43826. dispose(): void;
  43827. private _checkAnimationGroupEnded;
  43828. /**
  43829. * Clone the current animation group and returns a copy
  43830. * @param newName defines the name of the new group
  43831. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43832. * @returns the new aniamtion group
  43833. */
  43834. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43835. /**
  43836. * Serializes the animationGroup to an object
  43837. * @returns Serialized object
  43838. */
  43839. serialize(): any;
  43840. /**
  43841. * Returns a new AnimationGroup object parsed from the source provided.
  43842. * @param parsedAnimationGroup defines the source
  43843. * @param scene defines the scene that will receive the animationGroup
  43844. * @returns a new AnimationGroup
  43845. */
  43846. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43847. /**
  43848. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43849. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43850. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43851. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43852. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43853. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43854. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43855. */
  43856. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43857. /**
  43858. * Returns the string "AnimationGroup"
  43859. * @returns "AnimationGroup"
  43860. */
  43861. getClassName(): string;
  43862. /**
  43863. * Creates a detailled string about the object
  43864. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43865. * @returns a string representing the object
  43866. */
  43867. toString(fullDetails?: boolean): string;
  43868. }
  43869. }
  43870. declare module BABYLON {
  43871. /**
  43872. * @hidden
  43873. **/
  43874. export class _TimeToken {
  43875. _startTimeQuery: Nullable<WebGLQuery>;
  43876. _endTimeQuery: Nullable<WebGLQuery>;
  43877. _timeElapsedQuery: Nullable<WebGLQuery>;
  43878. _timeElapsedQueryEnded: boolean;
  43879. }
  43880. }
  43881. declare module BABYLON {
  43882. /** @hidden */
  43883. export enum ExtensionName {
  43884. DepthClamping = "depth-clamping",
  43885. Depth24UnormStencil8 = "depth24unorm-stencil8",
  43886. Depth32FloatStencil8 = "depth32float-stencil8",
  43887. PipelineStatisticsQuery = "pipeline-statistics-query",
  43888. TextureCompressionBC = "texture-compression-bc",
  43889. TimestampQuery = "timestamp-query"
  43890. }
  43891. /** @hidden */
  43892. export enum AddressMode {
  43893. ClampToEdge = "clamp-to-edge",
  43894. Repeat = "repeat",
  43895. MirrorRepeat = "mirror-repeat"
  43896. }
  43897. /** @hidden */
  43898. export enum BindingType {
  43899. UniformBuffer = "uniform-buffer",
  43900. StorageBuffer = "storage-buffer",
  43901. ReadonlyStorageBuffer = "readonly-storage-buffer",
  43902. Sampler = "sampler",
  43903. ComparisonSampler = "comparison-sampler",
  43904. SampledTexture = "sampled-texture",
  43905. ReadonlyStorageTexture = "readonly-storage-texture",
  43906. WriteonlyStorageTexture = "writeonly-storage-texture"
  43907. }
  43908. /** @hidden */
  43909. export enum BlendFactor {
  43910. Zero = "zero",
  43911. One = "one",
  43912. SrcColor = "src-color",
  43913. OneMinusSrcColor = "one-minus-src-color",
  43914. SrcAlpha = "src-alpha",
  43915. OneMinusSrcAlpha = "one-minus-src-alpha",
  43916. DstColor = "dst-color",
  43917. OneMinusDstColor = "one-minus-dst-color",
  43918. DstAlpha = "dst-alpha",
  43919. OneMinusDstAlpha = "one-minus-dst-alpha",
  43920. SrcAlphaSaturated = "src-alpha-saturated",
  43921. BlendColor = "blend-color",
  43922. OneMinusBlendColor = "one-minus-blend-color"
  43923. }
  43924. /** @hidden */
  43925. export enum BlendOperation {
  43926. Add = "add",
  43927. Subtract = "subtract",
  43928. ReverseSubtract = "reverse-subtract",
  43929. Min = "min",
  43930. Max = "max"
  43931. }
  43932. /** @hidden */
  43933. export enum CompareFunction {
  43934. Never = "never",
  43935. Less = "less",
  43936. Equal = "equal",
  43937. LessEqual = "less-equal",
  43938. Greater = "greater",
  43939. NotEqual = "not-equal",
  43940. GreaterEqual = "greater-equal",
  43941. Always = "always"
  43942. }
  43943. /** @hidden */
  43944. export enum CullMode {
  43945. None = "none",
  43946. Front = "front",
  43947. Back = "back"
  43948. }
  43949. /** @hidden */
  43950. export enum FilterMode {
  43951. Nearest = "nearest",
  43952. Linear = "linear"
  43953. }
  43954. /** @hidden */
  43955. export enum FrontFace {
  43956. CCW = "ccw",
  43957. CW = "cw"
  43958. }
  43959. /** @hidden */
  43960. export enum IndexFormat {
  43961. Uint16 = "uint16",
  43962. Uint32 = "uint32"
  43963. }
  43964. /** @hidden */
  43965. export enum InputStepMode {
  43966. Vertex = "vertex",
  43967. Instance = "instance"
  43968. }
  43969. /** @hidden */
  43970. export enum LoadOp {
  43971. Load = "load"
  43972. }
  43973. /** @hidden */
  43974. export enum PrimitiveTopology {
  43975. PointList = "point-list",
  43976. LineList = "line-list",
  43977. LineStrip = "line-strip",
  43978. TriangleList = "triangle-list",
  43979. TriangleStrip = "triangle-strip"
  43980. }
  43981. /** @hidden */
  43982. export enum StencilOperation {
  43983. Keep = "keep",
  43984. Zero = "zero",
  43985. Replace = "replace",
  43986. Invert = "invert",
  43987. IncrementClamp = "increment-clamp",
  43988. DecrementClamp = "decrement-clamp",
  43989. IncrementWrap = "increment-wrap",
  43990. DecrementWrap = "decrement-wrap"
  43991. }
  43992. /** @hidden */
  43993. export enum StoreOp {
  43994. Store = "store",
  43995. Clear = "clear"
  43996. }
  43997. /** @hidden */
  43998. export enum TextureDimension {
  43999. E1d = "1d",
  44000. E2d = "2d",
  44001. E3d = "3d"
  44002. }
  44003. /** @hidden */
  44004. export enum TextureFormat {
  44005. R8Unorm = "r8unorm",
  44006. R8Snorm = "r8snorm",
  44007. R8Uint = "r8uint",
  44008. R8Sint = "r8sint",
  44009. R16Uint = "r16uint",
  44010. R16Sint = "r16sint",
  44011. R16Float = "r16float",
  44012. RG8Unorm = "rg8unorm",
  44013. RG8Snorm = "rg8snorm",
  44014. RG8Uint = "rg8uint",
  44015. RG8Sint = "rg8sint",
  44016. R32Uint = "r32uint",
  44017. R32Sint = "r32sint",
  44018. R32Float = "r32float",
  44019. RG16Uint = "rg16uint",
  44020. RG16Sint = "rg16sint",
  44021. RG16Float = "rg16float",
  44022. RGBA8Unorm = "rgba8unorm",
  44023. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44024. RGBA8Snorm = "rgba8snorm",
  44025. RGBA8Uint = "rgba8uint",
  44026. RGBA8Sint = "rgba8sint",
  44027. BGRA8Unorm = "bgra8unorm",
  44028. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44029. RGB9E5UFloat = "rgb9e5ufloat",
  44030. RGB10A2Unorm = "rgb10a2unorm",
  44031. RG11B10UFloat = "rg11b10ufloat",
  44032. RG32Uint = "rg32uint",
  44033. RG32Sint = "rg32sint",
  44034. RG32Float = "rg32float",
  44035. RGBA16Uint = "rgba16uint",
  44036. RGBA16Sint = "rgba16sint",
  44037. RGBA16Float = "rgba16float",
  44038. RGBA32Uint = "rgba32uint",
  44039. RGBA32Sint = "rgba32sint",
  44040. RGBA32Float = "rgba32float",
  44041. Stencil8 = "stencil8",
  44042. Depth16Unorm = "depth16unorm",
  44043. Depth24Plus = "depth24plus",
  44044. Depth24PlusStencil8 = "depth24plus-stencil8",
  44045. Depth32Float = "depth32float",
  44046. BC1RGBAUNorm = "bc1-rgba-unorm",
  44047. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44048. BC2RGBAUnorm = "bc2-rgba-unorm",
  44049. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44050. BC3RGBAUnorm = "bc3-rgba-unorm",
  44051. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44052. BC4RUnorm = "bc4-r-unorm",
  44053. BC4RSnorm = "bc4-r-snorm",
  44054. BC5RGUnorm = "bc5-rg-unorm",
  44055. BC5RGSnorm = "bc5-rg-snorm",
  44056. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44057. BC6HRGBFloat = "bc6h-rgb-float",
  44058. BC7RGBAUnorm = "bc7-rgba-unorm",
  44059. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44060. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44061. Depth32FloatStencil8 = "depth32float-stencil8"
  44062. }
  44063. /** @hidden */
  44064. export enum TextureComponentType {
  44065. Float = "float",
  44066. Sint = "sint",
  44067. Uint = "uint",
  44068. DepthComparison = "depth-comparison"
  44069. }
  44070. /** @hidden */
  44071. export enum TextureViewDimension {
  44072. E1d = "1d",
  44073. E2d = "2d",
  44074. E2dArray = "2d-array",
  44075. Cube = "cube",
  44076. CubeArray = "cube-array",
  44077. E3d = "3d"
  44078. }
  44079. /** @hidden */
  44080. export enum VertexFormat {
  44081. Uchar2 = "uchar2",
  44082. Uchar4 = "uchar4",
  44083. Char2 = "char2",
  44084. Char4 = "char4",
  44085. Uchar2Norm = "uchar2norm",
  44086. Uchar4Norm = "uchar4norm",
  44087. Char2Norm = "char2norm",
  44088. Char4Norm = "char4norm",
  44089. Ushort2 = "ushort2",
  44090. Ushort4 = "ushort4",
  44091. Short2 = "short2",
  44092. Short4 = "short4",
  44093. Ushort2Norm = "ushort2norm",
  44094. Ushort4Norm = "ushort4norm",
  44095. Short2Norm = "short2norm",
  44096. Short4Norm = "short4norm",
  44097. Half2 = "half2",
  44098. Half4 = "half4",
  44099. Float = "float",
  44100. Float2 = "float2",
  44101. Float3 = "float3",
  44102. Float4 = "float4",
  44103. Uint = "uint",
  44104. Uint2 = "uint2",
  44105. Uint3 = "uint3",
  44106. Uint4 = "uint4",
  44107. Int = "int",
  44108. Int2 = "int2",
  44109. Int3 = "int3",
  44110. Int4 = "int4"
  44111. }
  44112. /** @hidden */
  44113. export enum TextureAspect {
  44114. All = "all",
  44115. StencilOnly = "stencil-only",
  44116. DepthOnly = "depth-only"
  44117. }
  44118. /** @hidden */
  44119. export enum CompilationMessageType {
  44120. Error = "error",
  44121. Warning = "warning",
  44122. Info = "info"
  44123. }
  44124. /** @hidden */
  44125. export enum QueryType {
  44126. Occlusion = "occlusion"
  44127. }
  44128. /** @hidden */
  44129. export enum BufferUsage {
  44130. MapRead = 1,
  44131. MapWrite = 2,
  44132. CopySrc = 4,
  44133. CopyDst = 8,
  44134. Index = 16,
  44135. Vertex = 32,
  44136. Uniform = 64,
  44137. Storage = 128,
  44138. Indirect = 256,
  44139. QueryResolve = 512
  44140. }
  44141. /** @hidden */
  44142. export enum ColorWrite {
  44143. Red = 1,
  44144. Green = 2,
  44145. Blue = 4,
  44146. Alpha = 8,
  44147. All = 15
  44148. }
  44149. /** @hidden */
  44150. export enum ShaderStage {
  44151. Vertex = 1,
  44152. Fragment = 2,
  44153. Compute = 4
  44154. }
  44155. /** @hidden */
  44156. export enum TextureUsage {
  44157. CopySrc = 1,
  44158. CopyDst = 2,
  44159. Sampled = 4,
  44160. Storage = 8,
  44161. OutputAttachment = 16
  44162. }
  44163. /** @hidden */
  44164. export enum MapMode {
  44165. Read = 1,
  44166. Write = 2
  44167. }
  44168. }
  44169. declare module BABYLON {
  44170. /** @hidden */
  44171. export interface WebGPUBindingInfo {
  44172. setIndex: number;
  44173. bindingIndex: number;
  44174. }
  44175. /** @hidden */
  44176. export interface WebGPUTextureSamplerBindingDescription {
  44177. sampler: WebGPUBindingInfo;
  44178. isTextureArray: boolean;
  44179. textures: Array<WebGPUBindingInfo>;
  44180. }
  44181. /** @hidden
  44182. * If the binding is a UBO, isSampler=isTexture=false
  44183. */
  44184. export interface WebGPUBindingDescription {
  44185. name: string;
  44186. usedInVertex: boolean;
  44187. usedInFragment: boolean;
  44188. isSampler: boolean;
  44189. isComparisonSampler?: boolean;
  44190. isTexture: boolean;
  44191. componentType?: GPUTextureComponentType;
  44192. textureDimension?: GPUTextureViewDimension;
  44193. }
  44194. /**
  44195. * @hidden
  44196. */
  44197. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44198. uboNextBindingIndex: number;
  44199. freeSetIndex: number;
  44200. freeBindingIndex: number;
  44201. availableVaryings: {
  44202. [key: string]: number;
  44203. };
  44204. availableAttributes: {
  44205. [key: string]: number;
  44206. };
  44207. availableUBOs: {
  44208. [key: string]: {
  44209. setIndex: number;
  44210. bindingIndex: number;
  44211. };
  44212. };
  44213. availableSamplers: {
  44214. [key: string]: WebGPUTextureSamplerBindingDescription;
  44215. };
  44216. leftOverUniforms: {
  44217. name: string;
  44218. type: string;
  44219. length: number;
  44220. }[];
  44221. orderedAttributes: string[];
  44222. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44223. private _attributeNextLocation;
  44224. private _varyingNextLocation;
  44225. constructor();
  44226. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44227. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44228. getNextFreeUBOBinding(): {
  44229. setIndex: number;
  44230. bindingIndex: number;
  44231. };
  44232. private _getNextFreeBinding;
  44233. }
  44234. }
  44235. declare module BABYLON {
  44236. /** @hidden */
  44237. export interface IWebGPUPipelineContextSamplerCache {
  44238. samplerBinding: number;
  44239. firstTextureName: string;
  44240. }
  44241. /** @hidden */
  44242. export interface IWebGPUPipelineContextTextureCache {
  44243. textureBinding: number;
  44244. texture: InternalTexture;
  44245. }
  44246. /** @hidden */
  44247. export interface IWebGPUPipelineContextVertexInputsCache {
  44248. indexBuffer: Nullable<GPUBuffer>;
  44249. indexOffset: number;
  44250. vertexStartSlot: number;
  44251. vertexBuffers: GPUBuffer[];
  44252. vertexOffsets: number[];
  44253. }
  44254. /** @hidden */
  44255. export interface IWebGPURenderPipelineStageDescriptor {
  44256. vertexStage: GPUProgrammableStageDescriptor;
  44257. fragmentStage?: GPUProgrammableStageDescriptor;
  44258. }
  44259. /** @hidden */
  44260. export class WebGPUPipelineContext implements IPipelineContext {
  44261. engine: WebGPUEngine;
  44262. shaderProcessingContext: WebGPUShaderProcessingContext;
  44263. leftOverUniformsByName: {
  44264. [name: string]: string;
  44265. };
  44266. sources: {
  44267. vertex: string;
  44268. fragment: string;
  44269. rawVertex: string;
  44270. rawFragment: string;
  44271. };
  44272. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44273. samplers: {
  44274. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44275. };
  44276. textures: {
  44277. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44278. };
  44279. bindGroupLayouts: GPUBindGroupLayout[];
  44280. /**
  44281. * Stores the uniform buffer
  44282. */
  44283. uniformBuffer: Nullable<UniformBuffer>;
  44284. onCompiled?: () => void;
  44285. get isAsync(): boolean;
  44286. get isReady(): boolean;
  44287. /** @hidden */
  44288. _name: string;
  44289. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44290. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44291. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44292. [key: string]: number;
  44293. }, uniformsNames: string[], uniforms: {
  44294. [key: string]: Nullable<WebGLUniformLocation>;
  44295. }, samplerList: string[], samplers: {
  44296. [key: string]: number;
  44297. }, attributesNames: string[], attributes: number[]): void;
  44298. /** @hidden */
  44299. /**
  44300. * Build the uniform buffer used in the material.
  44301. */
  44302. buildUniformLayout(): void;
  44303. /**
  44304. * Release all associated resources.
  44305. **/
  44306. dispose(): void;
  44307. /**
  44308. * Sets an integer value on a uniform variable.
  44309. * @param uniformName Name of the variable.
  44310. * @param value Value to be set.
  44311. */
  44312. setInt(uniformName: string, value: number): void;
  44313. /**
  44314. * Sets an int2 value on a uniform variable.
  44315. * @param uniformName Name of the variable.
  44316. * @param x First int in int2.
  44317. * @param y Second int in int2.
  44318. */
  44319. setInt2(uniformName: string, x: number, y: number): void;
  44320. /**
  44321. * Sets an int3 value on a uniform variable.
  44322. * @param uniformName Name of the variable.
  44323. * @param x First int in int3.
  44324. * @param y Second int in int3.
  44325. * @param z Third int in int3.
  44326. */
  44327. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44328. /**
  44329. * Sets an int4 value on a uniform variable.
  44330. * @param uniformName Name of the variable.
  44331. * @param x First int in int4.
  44332. * @param y Second int in int4.
  44333. * @param z Third int in int4.
  44334. * @param w Fourth int in int4.
  44335. */
  44336. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44337. /**
  44338. * Sets an int array on a uniform variable.
  44339. * @param uniformName Name of the variable.
  44340. * @param array array to be set.
  44341. */
  44342. setIntArray(uniformName: string, array: Int32Array): void;
  44343. /**
  44344. * 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)
  44345. * @param uniformName Name of the variable.
  44346. * @param array array to be set.
  44347. */
  44348. setIntArray2(uniformName: string, array: Int32Array): void;
  44349. /**
  44350. * 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)
  44351. * @param uniformName Name of the variable.
  44352. * @param array array to be set.
  44353. */
  44354. setIntArray3(uniformName: string, array: Int32Array): void;
  44355. /**
  44356. * 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)
  44357. * @param uniformName Name of the variable.
  44358. * @param array array to be set.
  44359. */
  44360. setIntArray4(uniformName: string, array: Int32Array): void;
  44361. /**
  44362. * Sets an array on a uniform variable.
  44363. * @param uniformName Name of the variable.
  44364. * @param array array to be set.
  44365. */
  44366. setArray(uniformName: string, array: number[]): void;
  44367. /**
  44368. * 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)
  44369. * @param uniformName Name of the variable.
  44370. * @param array array to be set.
  44371. */
  44372. setArray2(uniformName: string, array: number[]): void;
  44373. /**
  44374. * 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)
  44375. * @param uniformName Name of the variable.
  44376. * @param array array to be set.
  44377. * @returns this effect.
  44378. */
  44379. setArray3(uniformName: string, array: number[]): void;
  44380. /**
  44381. * 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)
  44382. * @param uniformName Name of the variable.
  44383. * @param array array to be set.
  44384. */
  44385. setArray4(uniformName: string, array: number[]): void;
  44386. /**
  44387. * Sets matrices on a uniform variable.
  44388. * @param uniformName Name of the variable.
  44389. * @param matrices matrices to be set.
  44390. */
  44391. setMatrices(uniformName: string, matrices: Float32Array): void;
  44392. /**
  44393. * Sets matrix on a uniform variable.
  44394. * @param uniformName Name of the variable.
  44395. * @param matrix matrix to be set.
  44396. */
  44397. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44398. /**
  44399. * 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)
  44400. * @param uniformName Name of the variable.
  44401. * @param matrix matrix to be set.
  44402. */
  44403. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44404. /**
  44405. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44406. * @param uniformName Name of the variable.
  44407. * @param matrix matrix to be set.
  44408. */
  44409. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44410. /**
  44411. * Sets a float on a uniform variable.
  44412. * @param uniformName Name of the variable.
  44413. * @param value value to be set.
  44414. * @returns this effect.
  44415. */
  44416. setFloat(uniformName: string, value: number): void;
  44417. /**
  44418. * Sets a Vector2 on a uniform variable.
  44419. * @param uniformName Name of the variable.
  44420. * @param vector2 vector2 to be set.
  44421. */
  44422. setVector2(uniformName: string, vector2: IVector2Like): void;
  44423. /**
  44424. * Sets a float2 on a uniform variable.
  44425. * @param uniformName Name of the variable.
  44426. * @param x First float in float2.
  44427. * @param y Second float in float2.
  44428. */
  44429. setFloat2(uniformName: string, x: number, y: number): void;
  44430. /**
  44431. * Sets a Vector3 on a uniform variable.
  44432. * @param uniformName Name of the variable.
  44433. * @param vector3 Value to be set.
  44434. */
  44435. setVector3(uniformName: string, vector3: IVector3Like): void;
  44436. /**
  44437. * Sets a float3 on a uniform variable.
  44438. * @param uniformName Name of the variable.
  44439. * @param x First float in float3.
  44440. * @param y Second float in float3.
  44441. * @param z Third float in float3.
  44442. */
  44443. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44444. /**
  44445. * Sets a Vector4 on a uniform variable.
  44446. * @param uniformName Name of the variable.
  44447. * @param vector4 Value to be set.
  44448. */
  44449. setVector4(uniformName: string, vector4: IVector4Like): void;
  44450. /**
  44451. * Sets a float4 on a uniform variable.
  44452. * @param uniformName Name of the variable.
  44453. * @param x First float in float4.
  44454. * @param y Second float in float4.
  44455. * @param z Third float in float4.
  44456. * @param w Fourth float in float4.
  44457. * @returns this effect.
  44458. */
  44459. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44460. /**
  44461. * Sets a Color3 on a uniform variable.
  44462. * @param uniformName Name of the variable.
  44463. * @param color3 Value to be set.
  44464. */
  44465. setColor3(uniformName: string, color3: IColor3Like): void;
  44466. /**
  44467. * Sets a Color4 on a uniform variable.
  44468. * @param uniformName Name of the variable.
  44469. * @param color3 Value to be set.
  44470. * @param alpha Alpha value to be set.
  44471. */
  44472. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44473. /**
  44474. * Sets a Color4 on a uniform variable
  44475. * @param uniformName defines the name of the variable
  44476. * @param color4 defines the value to be set
  44477. */
  44478. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44479. _getVertexShaderCode(): string | null;
  44480. _getFragmentShaderCode(): string | null;
  44481. }
  44482. }
  44483. declare module BABYLON {
  44484. /** @hidden */
  44485. export class WebGPUDataBuffer extends DataBuffer {
  44486. private _buffer;
  44487. constructor(resource: GPUBuffer);
  44488. get underlyingResource(): any;
  44489. }
  44490. }
  44491. declare module BABYLON {
  44492. /**
  44493. * Class used to inline functions in shader code
  44494. */
  44495. export class ShaderCodeInliner {
  44496. private static readonly _RegexpFindFunctionNameAndType;
  44497. private _sourceCode;
  44498. private _functionDescr;
  44499. private _numMaxIterations;
  44500. /** Gets or sets the token used to mark the functions to inline */
  44501. inlineToken: string;
  44502. /** Gets or sets the debug mode */
  44503. debug: boolean;
  44504. /** Gets the code after the inlining process */
  44505. get code(): string;
  44506. /**
  44507. * Initializes the inliner
  44508. * @param sourceCode shader code source to inline
  44509. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44510. */
  44511. constructor(sourceCode: string, numMaxIterations?: number);
  44512. /**
  44513. * Start the processing of the shader code
  44514. */
  44515. processCode(): void;
  44516. private _collectFunctions;
  44517. private _processInlining;
  44518. private _extractBetweenMarkers;
  44519. private _skipWhitespaces;
  44520. private _isIdentifierChar;
  44521. private _removeComments;
  44522. private _replaceFunctionCallsByCode;
  44523. private _findBackward;
  44524. private _escapeRegExp;
  44525. private _replaceNames;
  44526. }
  44527. }
  44528. declare module BABYLON {
  44529. /** @hidden */
  44530. export class WebGPUShaderProcessor implements IShaderProcessor {
  44531. protected _missingVaryings: Array<string>;
  44532. protected _textureArrayProcessing: Array<string>;
  44533. protected _preProcessors: {
  44534. [key: string]: string;
  44535. };
  44536. private _getArraySize;
  44537. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44538. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44539. [key: string]: string;
  44540. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44541. attributeProcessor(attribute: string, preProcessors: {
  44542. [key: string]: string;
  44543. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44544. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44545. [key: string]: string;
  44546. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44547. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44548. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44549. private _applyTextureArrayProcessing;
  44550. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44551. vertexCode: string;
  44552. fragmentCode: string;
  44553. };
  44554. }
  44555. }
  44556. declare module BABYLON {
  44557. /** @hidden */
  44558. export class WebGPUBufferManager {
  44559. private _device;
  44560. private _deferredReleaseBuffers;
  44561. private static _IsGPUBuffer;
  44562. constructor(device: GPUDevice);
  44563. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  44564. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  44565. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  44566. private _FromHalfFloat;
  44567. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  44568. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  44569. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  44570. destroyDeferredBuffers(): void;
  44571. }
  44572. }
  44573. declare module BABYLON {
  44574. /** @hidden */
  44575. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  44576. private _webgpuTexture;
  44577. private _webgpuMSAATexture;
  44578. get underlyingResource(): Nullable<GPUTexture>;
  44579. get msaaTexture(): Nullable<GPUTexture>;
  44580. set msaaTexture(texture: Nullable<GPUTexture>);
  44581. view: Nullable<GPUTextureView>;
  44582. format: GPUTextureFormat;
  44583. textureUsages: number;
  44584. constructor(existingTexture?: Nullable<GPUTexture>);
  44585. set(hardwareTexture: GPUTexture): void;
  44586. setMSAATexture(hardwareTexture: GPUTexture): void;
  44587. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  44588. createView(descriptor?: GPUTextureViewDescriptor): void;
  44589. reset(): void;
  44590. release(): void;
  44591. }
  44592. }
  44593. declare module BABYLON {
  44594. /** @hidden */
  44595. export class WebGPUTextureHelper {
  44596. private _device;
  44597. private _glslang;
  44598. private _bufferManager;
  44599. private _mipmapSampler;
  44600. private _invertYPreMultiplyAlphaSampler;
  44601. private _pipelines;
  44602. private _compiledShaders;
  44603. private _deferredReleaseTextures;
  44604. private _commandEncoderForCreation;
  44605. static ComputeNumMipmapLevels(width: number, height: number): number;
  44606. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  44607. private _getPipeline;
  44608. private static _GetTextureTypeFromFormat;
  44609. private static _GetBlockInformationFromFormat;
  44610. private static _IsHardwareTexture;
  44611. private static _IsInternalTexture;
  44612. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  44613. static IsImageBitmap(imageBitmap: ImageBitmap | {
  44614. width: number;
  44615. height: number;
  44616. }): imageBitmap is ImageBitmap;
  44617. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  44618. width: number;
  44619. height: number;
  44620. }): imageBitmap is ImageBitmap[];
  44621. setCommandEncoder(encoder: GPUCommandEncoder): void;
  44622. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  44623. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  44624. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44625. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  44626. createTexture(imageBitmap: ImageBitmap | {
  44627. width: number;
  44628. height: number;
  44629. layers: number;
  44630. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44631. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  44632. width: number;
  44633. height: number;
  44634. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44635. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  44636. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44637. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  44638. createMSAATexture(texture: InternalTexture, samples: number): void;
  44639. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44640. 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;
  44641. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  44642. releaseTexture(texture: InternalTexture | GPUTexture): void;
  44643. destroyDeferredTextures(): void;
  44644. }
  44645. }
  44646. declare module BABYLON {
  44647. /** @hidden */
  44648. export class WebGPURenderPassWrapper {
  44649. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  44650. renderPass: Nullable<GPURenderPassEncoder>;
  44651. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44652. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44653. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  44654. depthTextureFormat: GPUTextureFormat | undefined;
  44655. constructor();
  44656. reset(fullReset?: boolean): void;
  44657. }
  44658. }
  44659. declare module BABYLON {
  44660. /** @hidden */
  44661. export class WebGPUCacheSampler {
  44662. private _samplers;
  44663. private _device;
  44664. constructor(device: GPUDevice);
  44665. private static _GetSamplerHashCode;
  44666. private static _GetSamplerFilterDescriptor;
  44667. private static _GetWrappingMode;
  44668. private static _GetSamplerWrappingDescriptor;
  44669. private static _GetSamplerDescriptor;
  44670. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  44671. }
  44672. }
  44673. declare module BABYLON {
  44674. /** @hidden */
  44675. export class WebGPUShaderManager {
  44676. private _shaders;
  44677. private _device;
  44678. constructor(device: GPUDevice);
  44679. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  44680. }
  44681. }
  44682. declare module BABYLON {
  44683. /** @hidden */
  44684. export var clearQuadVertexShader: {
  44685. name: string;
  44686. shader: string;
  44687. };
  44688. }
  44689. declare module BABYLON {
  44690. /** @hidden */
  44691. export var clearQuadPixelShader: {
  44692. name: string;
  44693. shader: string;
  44694. };
  44695. }
  44696. declare module BABYLON {
  44697. /**
  44698. * Options to load the associated Glslang library
  44699. */
  44700. export interface GlslangOptions {
  44701. /**
  44702. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  44703. */
  44704. glslang?: any;
  44705. /**
  44706. * Defines the URL of the glslang JS File.
  44707. */
  44708. jsPath?: string;
  44709. /**
  44710. * Defines the URL of the glslang WASM File.
  44711. */
  44712. wasmPath?: string;
  44713. }
  44714. /**
  44715. * Options to create the WebGPU engine
  44716. */
  44717. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  44718. /**
  44719. * If delta time between frames should be constant
  44720. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44721. */
  44722. deterministicLockstep?: boolean;
  44723. /**
  44724. * Maximum about of steps between frames (Default: 4)
  44725. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44726. */
  44727. lockstepMaxSteps?: number;
  44728. /**
  44729. * Defines the seconds between each deterministic lock step
  44730. */
  44731. timeStep?: number;
  44732. /**
  44733. * Defines that engine should ignore modifying touch action attribute and style
  44734. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  44735. */
  44736. doNotHandleTouchAction?: boolean;
  44737. /**
  44738. * Defines if webaudio should be initialized as well
  44739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  44740. */
  44741. audioEngine?: boolean;
  44742. /**
  44743. * Defines the category of adapter to use.
  44744. * Is it the discrete or integrated device.
  44745. */
  44746. powerPreference?: GPUPowerPreference;
  44747. /**
  44748. * Defines the device descriptor used to create a device.
  44749. */
  44750. deviceDescriptor?: GPUDeviceDescriptor;
  44751. /**
  44752. * Defines the requested Swap Chain Format.
  44753. */
  44754. swapChainFormat?: GPUTextureFormat;
  44755. /**
  44756. * Defines wether MSAA is enabled on the canvas.
  44757. */
  44758. antialiasing?: boolean;
  44759. /**
  44760. * Defines wether the stencil buffer should be enabled.
  44761. */
  44762. stencil?: boolean;
  44763. /**
  44764. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  44765. */
  44766. enableGPUDebugMarkers?: boolean;
  44767. /**
  44768. * Options to load the associated Glslang library
  44769. */
  44770. glslangOptions?: GlslangOptions;
  44771. }
  44772. /**
  44773. * The web GPU engine class provides support for WebGPU version of babylon.js.
  44774. */
  44775. export class WebGPUEngine extends Engine {
  44776. private static readonly _glslangDefaultOptions;
  44777. private readonly _uploadEncoderDescriptor;
  44778. private readonly _renderEncoderDescriptor;
  44779. private readonly _renderTargetEncoderDescriptor;
  44780. private readonly _clearDepthValue;
  44781. private readonly _clearReverseDepthValue;
  44782. private readonly _clearStencilValue;
  44783. private readonly _defaultSampleCount;
  44784. private _canvas;
  44785. private _options;
  44786. private _glslang;
  44787. private _adapter;
  44788. private _adapterSupportedExtensions;
  44789. private _device;
  44790. private _deviceEnabledExtensions;
  44791. private _context;
  44792. private _swapChain;
  44793. private _swapChainTexture;
  44794. private _mainPassSampleCount;
  44795. private _textureHelper;
  44796. private _bufferManager;
  44797. private _shaderManager;
  44798. private _cacheSampler;
  44799. private _emptyVertexBuffer;
  44800. private _lastCachedWrapU;
  44801. private _lastCachedWrapV;
  44802. private _lastCachedWrapR;
  44803. private _mrtAttachments;
  44804. private _counters;
  44805. private _mainTexture;
  44806. private _depthTexture;
  44807. private _mainTextureExtends;
  44808. private _depthTextureFormat;
  44809. private _colorFormat;
  44810. private _uploadEncoder;
  44811. private _renderEncoder;
  44812. private _renderTargetEncoder;
  44813. private _commandBuffers;
  44814. private _currentRenderPass;
  44815. private _mainRenderPassWrapper;
  44816. private _rttRenderPassWrapper;
  44817. private _pendingDebugCommands;
  44818. private _currentVertexBuffers;
  44819. private _currentIndexBuffer;
  44820. private __colorWrite;
  44821. private _uniformsBuffers;
  44822. private _forceEnableEffect;
  44823. /** @hidden */
  44824. dbgShowShaderCode: boolean;
  44825. /** @hidden */
  44826. dbgSanityChecks: boolean;
  44827. /** @hidden */
  44828. dbgGenerateLogs: boolean;
  44829. /** @hidden */
  44830. dbgVerboseLogsForFirstFrames: boolean;
  44831. /** @hidden */
  44832. dbgVerboseLogsNumFrames: number;
  44833. /** @hidden */
  44834. dbgShowWarningsNotImplemented: boolean;
  44835. /**
  44836. * Gets a boolean indicating if the engine can be instanciated (ie. if a WebGPU context can be found)
  44837. * @returns true if the engine can be created
  44838. */
  44839. static get IsSupported(): boolean;
  44840. /**
  44841. * Gets a boolean indicating that the engine supports uniform buffers
  44842. */
  44843. get supportsUniformBuffers(): boolean;
  44844. /** Gets the supported extensions by the WebGPU adapter */
  44845. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  44846. /** Gets the currently enabled extensions on the WebGPU device */
  44847. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  44848. /**
  44849. * Returns the name of the engine
  44850. */
  44851. get name(): string;
  44852. /**
  44853. * Returns a string describing the current engine
  44854. */
  44855. get description(): string;
  44856. /**
  44857. * Returns the version of the engine
  44858. */
  44859. get version(): number;
  44860. /**
  44861. * Create a new instance of the gpu engine asynchronously
  44862. * @param canvas Defines the canvas to use to display the result
  44863. * @param options Defines the options passed to the engine to create the GPU context dependencies
  44864. * @returns a promise that resolves with the created engine
  44865. */
  44866. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  44867. /**
  44868. * Create a new instance of the gpu engine.
  44869. * @param canvas Defines the canvas to use to display the result
  44870. * @param options Defines the options passed to the engine to create the GPU context dependencies
  44871. */
  44872. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  44873. /**
  44874. * Initializes the WebGPU context and dependencies.
  44875. * @param glslangOptions Defines the GLSLang compiler options if necessary
  44876. * @returns a promise notifying the readiness of the engine.
  44877. */
  44878. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  44879. private _initGlslang;
  44880. private _initializeLimits;
  44881. private _initializeContextAndSwapChain;
  44882. private _initializeMainAttachments;
  44883. /**
  44884. * Force a specific size of the canvas
  44885. * @param width defines the new canvas' width
  44886. * @param height defines the new canvas' height
  44887. * @param forceSetSize true to force setting the sizes of the underlying canvas
  44888. * @returns true if the size was changed
  44889. */
  44890. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  44891. /**
  44892. * Gets a shader processor implementation fitting with the current engine type.
  44893. * @returns The shader processor implementation.
  44894. */
  44895. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  44896. /** @hidden */
  44897. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  44898. /**
  44899. * Force the entire cache to be cleared
  44900. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  44901. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  44902. */
  44903. wipeCaches(bruteForce?: boolean): void;
  44904. /**
  44905. * Enable or disable color writing
  44906. * @param enable defines the state to set
  44907. */
  44908. setColorWrite(enable: boolean): void;
  44909. /**
  44910. * Gets a boolean indicating if color writing is enabled
  44911. * @returns the current color writing state
  44912. */
  44913. getColorWrite(): boolean;
  44914. private _viewportsCurrent;
  44915. private _resetCurrentViewport;
  44916. private _applyViewport;
  44917. /** @hidden */
  44918. _viewport(x: number, y: number, width: number, height: number): void;
  44919. private _scissorsCurrent;
  44920. protected _scissorCached: {
  44921. x: number;
  44922. y: number;
  44923. z: number;
  44924. w: number;
  44925. };
  44926. private _resetCurrentScissor;
  44927. private _applyScissor;
  44928. private _scissorIsActive;
  44929. enableScissor(x: number, y: number, width: number, height: number): void;
  44930. disableScissor(): void;
  44931. /**
  44932. * Clear the current render buffer or the current render target (if any is set up)
  44933. * @param color defines the color to use
  44934. * @param backBuffer defines if the back buffer must be cleared
  44935. * @param depth defines if the depth buffer must be cleared
  44936. * @param stencil defines if the stencil buffer must be cleared
  44937. */
  44938. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44939. /**
  44940. * Clears a list of attachments
  44941. * @param attachments list of the attachments
  44942. * @param colorMain clear color for the main attachment (the first one)
  44943. * @param colorOthers clear color for the other attachments
  44944. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  44945. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  44946. */
  44947. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  44948. /**
  44949. * Creates a vertex buffer
  44950. * @param data the data for the vertex buffer
  44951. * @returns the new buffer
  44952. */
  44953. createVertexBuffer(data: DataArray): DataBuffer;
  44954. /**
  44955. * Creates a vertex buffer
  44956. * @param data the data for the dynamic vertex buffer
  44957. * @returns the new buffer
  44958. */
  44959. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44960. /**
  44961. * Updates a vertex buffer.
  44962. * @param vertexBuffer the vertex buffer to update
  44963. * @param data the data used to update the vertex buffer
  44964. * @param byteOffset the byte offset of the data
  44965. * @param byteLength the byte length of the data
  44966. */
  44967. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44968. /**
  44969. * Creates a new index buffer
  44970. * @param indices defines the content of the index buffer
  44971. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  44972. * @returns a new buffer
  44973. */
  44974. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  44975. /**
  44976. * Update an index buffer
  44977. * @param indexBuffer defines the target index buffer
  44978. * @param indices defines the data to update
  44979. * @param offset defines the offset in the target index buffer where update should start
  44980. */
  44981. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44982. /** @hidden */
  44983. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  44984. /** @hidden */
  44985. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  44986. /**
  44987. * Bind a list of vertex buffers with the engine
  44988. * @param vertexBuffers defines the list of vertex buffers to bind
  44989. * @param indexBuffer defines the index buffer to bind
  44990. * @param effect defines the effect associated with the vertex buffers
  44991. */
  44992. bindBuffers(vertexBuffers: {
  44993. [key: string]: Nullable<VertexBuffer>;
  44994. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  44995. /** @hidden */
  44996. _releaseBuffer(buffer: DataBuffer): boolean;
  44997. createUniformBuffer(elements: FloatArray): DataBuffer;
  44998. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  44999. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  45000. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  45001. /**
  45002. * Create a new effect (used to store vertex/fragment shaders)
  45003. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  45004. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  45005. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  45006. * @param samplers defines an array of string used to represent textures
  45007. * @param defines defines the string containing the defines to use to compile the shaders
  45008. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  45009. * @param onCompiled defines a function to call when the effect creation is successful
  45010. * @param onError defines a function to call when the effect creation has failed
  45011. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  45012. * @returns the new Effect
  45013. */
  45014. 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;
  45015. private _compileRawShaderToSpirV;
  45016. private _compileShaderToSpirV;
  45017. private _createPipelineStageDescriptor;
  45018. private _compileRawPipelineStageDescriptor;
  45019. private _compilePipelineStageDescriptor;
  45020. /** @hidden */
  45021. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45022. /** @hidden */
  45023. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45024. /**
  45025. * Creates a new pipeline context
  45026. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  45027. * @returns the new pipeline
  45028. */
  45029. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  45030. /** @hidden */
  45031. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  45032. /**
  45033. * Gets the list of active attributes for a given WebGPU program
  45034. * @param pipelineContext defines the pipeline context to use
  45035. * @param attributesNames defines the list of attribute names to get
  45036. * @returns an array of indices indicating the offset of each attribute
  45037. */
  45038. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45039. /**
  45040. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45041. * @param effect defines the effect to activate
  45042. */
  45043. enableEffect(effect: Nullable<Effect>): void;
  45044. /** @hidden */
  45045. _releaseEffect(effect: Effect): void;
  45046. /**
  45047. * 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
  45048. */
  45049. releaseEffects(): void;
  45050. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45051. /**
  45052. * Gets a boolean indicating that only power of 2 textures are supported
  45053. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45054. */
  45055. get needPOTTextures(): boolean;
  45056. /** @hidden */
  45057. _createHardwareTexture(): HardwareTextureWrapper;
  45058. /** @hidden */
  45059. _releaseTexture(texture: InternalTexture): void;
  45060. /** @hidden */
  45061. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45062. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45063. /**
  45064. * Usually called from Texture.ts.
  45065. * Passed information to create a hardware texture
  45066. * @param url defines a value which contains one of the following:
  45067. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45068. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45069. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45070. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45071. * @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)
  45072. * @param scene needed for loading to the correct scene
  45073. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45074. * @param onLoad optional callback to be called upon successful completion
  45075. * @param onError optional callback to be called upon failure
  45076. * @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
  45077. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45078. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45079. * @param forcedExtension defines the extension to use to pick the right loader
  45080. * @param mimeType defines an optional mime type
  45081. * @param loaderOptions options to be passed to the loader
  45082. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45083. */
  45084. 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;
  45085. /** @hidden */
  45086. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45087. /**
  45088. * Creates a cube texture
  45089. * @param rootUrl defines the url where the files to load is located
  45090. * @param scene defines the current scene
  45091. * @param files defines the list of files to load (1 per face)
  45092. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45093. * @param onLoad defines an optional callback raised when the texture is loaded
  45094. * @param onError defines an optional callback raised if there is an issue to load the texture
  45095. * @param format defines the format of the data
  45096. * @param forcedExtension defines the extension to use to pick the right loader
  45097. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45098. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45099. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45100. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45101. * @param loaderOptions options to be passed to the loader
  45102. * @returns the cube texture as an InternalTexture
  45103. */
  45104. 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;
  45105. /**
  45106. * Creates a raw texture
  45107. * @param data defines the data to store in the texture
  45108. * @param width defines the width of the texture
  45109. * @param height defines the height of the texture
  45110. * @param format defines the format of the data
  45111. * @param generateMipMaps defines if the engine should generate the mip levels
  45112. * @param invertY defines if data must be stored with Y axis inverted
  45113. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45114. * @param compression defines the compression used (null by default)
  45115. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45116. * @returns the raw texture inside an InternalTexture
  45117. */
  45118. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45119. /**
  45120. * Creates a new raw cube texture
  45121. * @param data defines the array of data to use to create each face
  45122. * @param size defines the size of the textures
  45123. * @param format defines the format of the data
  45124. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45125. * @param generateMipMaps defines if the engine should generate the mip levels
  45126. * @param invertY defines if data must be stored with Y axis inverted
  45127. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45128. * @param compression defines the compression used (null by default)
  45129. * @returns the cube texture as an InternalTexture
  45130. */
  45131. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45132. /**
  45133. * Creates a new raw cube texture from a specified url
  45134. * @param url defines the url where the data is located
  45135. * @param scene defines the current scene
  45136. * @param size defines the size of the textures
  45137. * @param format defines the format of the data
  45138. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45139. * @param noMipmap defines if the engine should avoid generating the mip levels
  45140. * @param callback defines a callback used to extract texture data from loaded data
  45141. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45142. * @param onLoad defines a callback called when texture is loaded
  45143. * @param onError defines a callback called if there is an error
  45144. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45145. * @param invertY defines if data must be stored with Y axis inverted
  45146. * @returns the cube texture as an InternalTexture
  45147. */
  45148. 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;
  45149. /**
  45150. * Creates a new raw 2D array texture
  45151. * @param data defines the data used to create the texture
  45152. * @param width defines the width of the texture
  45153. * @param height defines the height of the texture
  45154. * @param depth defines the number of layers of the texture
  45155. * @param format defines the format of the texture
  45156. * @param generateMipMaps defines if the engine must generate mip levels
  45157. * @param invertY defines if data must be stored with Y axis inverted
  45158. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45159. * @param compression defines the compressed used (can be null)
  45160. * @param textureType defines the compressed used (can be null)
  45161. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45162. */
  45163. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45164. /**
  45165. * Creates a new raw 3D texture
  45166. * @param data defines the data used to create the texture
  45167. * @param width defines the width of the texture
  45168. * @param height defines the height of the texture
  45169. * @param depth defines the depth of the texture
  45170. * @param format defines the format of the texture
  45171. * @param generateMipMaps defines if the engine must generate mip levels
  45172. * @param invertY defines if data must be stored with Y axis inverted
  45173. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45174. * @param compression defines the compressed used (can be null)
  45175. * @param textureType defines the compressed used (can be null)
  45176. * @returns a new raw 3D texture (stored in an InternalTexture)
  45177. */
  45178. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45179. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45180. /**
  45181. * Update the sampling mode of a given texture
  45182. * @param samplingMode defines the required sampling mode
  45183. * @param texture defines the texture to update
  45184. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45185. */
  45186. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45187. /**
  45188. * Update the sampling mode of a given texture
  45189. * @param texture defines the texture to update
  45190. * @param wrapU defines the texture wrap mode of the u coordinates
  45191. * @param wrapV defines the texture wrap mode of the v coordinates
  45192. * @param wrapR defines the texture wrap mode of the r coordinates
  45193. */
  45194. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45195. /**
  45196. * Update the dimensions of a texture
  45197. * @param texture texture to update
  45198. * @param width new width of the texture
  45199. * @param height new height of the texture
  45200. * @param depth new depth of the texture
  45201. */
  45202. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45203. private _setInternalTexture;
  45204. /**
  45205. * Sets a texture to the according uniform.
  45206. * @param channel The texture channel
  45207. * @param unused unused parameter
  45208. * @param texture The texture to apply
  45209. * @param name The name of the uniform in the effect
  45210. */
  45211. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45212. /**
  45213. * Sets an array of texture to the WebGPU context
  45214. * @param channel defines the channel where the texture array must be set
  45215. * @param unused unused parameter
  45216. * @param textures defines the array of textures to bind
  45217. * @param name name of the channel
  45218. */
  45219. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45220. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45221. /** @hidden */
  45222. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45223. /** @hidden */
  45224. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45225. private _generateMipmaps;
  45226. /**
  45227. * Update the content of a texture
  45228. * @param texture defines the texture to update
  45229. * @param canvas defines the source containing the data
  45230. * @param invertY defines if data must be stored with Y axis inverted
  45231. * @param premulAlpha defines if alpha is stored as premultiplied
  45232. * @param format defines the format of the data
  45233. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45234. */
  45235. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45236. /**
  45237. * Update a portion of an internal texture
  45238. * @param texture defines the texture to update
  45239. * @param imageData defines the data to store into the texture
  45240. * @param xOffset defines the x coordinates of the update rectangle
  45241. * @param yOffset defines the y coordinates of the update rectangle
  45242. * @param width defines the width of the update rectangle
  45243. * @param height defines the height of the update rectangle
  45244. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45245. * @param lod defines the lod level to update (0 by default)
  45246. */
  45247. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45248. /**
  45249. * Update a video texture
  45250. * @param texture defines the texture to update
  45251. * @param video defines the video element to use
  45252. * @param invertY defines if data must be stored with Y axis inverted
  45253. */
  45254. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45255. /** @hidden */
  45256. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45257. /** @hidden */
  45258. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45259. /** @hidden */
  45260. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45261. /** @hidden */
  45262. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45263. /**
  45264. * Update a raw texture
  45265. * @param texture defines the texture to update
  45266. * @param bufferView defines the data to store in the texture
  45267. * @param format defines the format of the data
  45268. * @param invertY defines if data must be stored with Y axis inverted
  45269. * @param compression defines the compression used (null by default)
  45270. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45271. */
  45272. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45273. /**
  45274. * Update a raw cube texture
  45275. * @param texture defines the texture to udpdate
  45276. * @param bufferView defines the data to store
  45277. * @param format defines the data format
  45278. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45279. * @param invertY defines if data must be stored with Y axis inverted
  45280. * @param compression defines the compression used (null by default)
  45281. * @param level defines which level of the texture to update
  45282. */
  45283. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45284. /**
  45285. * Update a raw 2D array texture
  45286. * @param texture defines the texture to update
  45287. * @param bufferView defines the data to store
  45288. * @param format defines the data format
  45289. * @param invertY defines if data must be stored with Y axis inverted
  45290. * @param compression defines the used compression (can be null)
  45291. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45292. */
  45293. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45294. /**
  45295. * Update a raw 3D texture
  45296. * @param texture defines the texture to update
  45297. * @param bufferView defines the data to store
  45298. * @param format defines the data format
  45299. * @param invertY defines if data must be stored with Y axis inverted
  45300. * @param compression defines the used compression (can be null)
  45301. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45302. */
  45303. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45304. /**
  45305. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45306. * @param x defines the x coordinate of the rectangle where pixels must be read
  45307. * @param y defines the y coordinate of the rectangle where pixels must be read
  45308. * @param width defines the width of the rectangle where pixels must be read
  45309. * @param height defines the height of the rectangle where pixels must be read
  45310. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45311. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45312. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45313. */
  45314. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45315. /** @hidden */
  45316. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45317. /**
  45318. * Creates a new render target texture
  45319. * @param size defines the size of the texture
  45320. * @param options defines the options used to create the texture
  45321. * @returns a new render target texture stored in an InternalTexture
  45322. */
  45323. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45324. /**
  45325. * Create a multi render target texture
  45326. * @param size defines the size of the texture
  45327. * @param options defines the creation options
  45328. * @returns the cube texture as an InternalTexture
  45329. */
  45330. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45331. /**
  45332. * Creates a new render target cube texture
  45333. * @param size defines the size of the texture
  45334. * @param options defines the options used to create the texture
  45335. * @returns a new render target cube texture stored in an InternalTexture
  45336. */
  45337. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45338. /** @hidden */
  45339. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45340. width: number;
  45341. height: number;
  45342. layers?: number;
  45343. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45344. /** @hidden */
  45345. _createDepthStencilTexture(size: number | {
  45346. width: number;
  45347. height: number;
  45348. layers?: number;
  45349. }, options: DepthTextureCreationOptions): InternalTexture;
  45350. /** @hidden */
  45351. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  45352. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  45353. /**
  45354. * Update the sample count for a given multiple render target texture
  45355. * @param textures defines the textures to update
  45356. * @param samples defines the sample count to set
  45357. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45358. */
  45359. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45360. /**
  45361. * Begin a new frame
  45362. */
  45363. beginFrame(): void;
  45364. /**
  45365. * End the current frame
  45366. */
  45367. endFrame(): void;
  45368. /**
  45369. * Force a WebGPU flush (ie. a flush of all waiting commands)
  45370. */
  45371. flushFramebuffer(): void;
  45372. private _startRenderTargetRenderPass;
  45373. private _endRenderTargetRenderPass;
  45374. private _getCurrentRenderPass;
  45375. private _currentRenderPassIsMRT;
  45376. private _startMainRenderPass;
  45377. private _endMainRenderPass;
  45378. /**
  45379. * Restores the WebGPU state to only draw on the main color attachment
  45380. */
  45381. restoreSingleAttachment(): void;
  45382. /**
  45383. * Creates a layout object to draw/clear on specific textures in a MRT
  45384. * @param textureStatus textureStatus[i] indicates if the i-th is active
  45385. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  45386. */
  45387. buildTextureLayout(textureStatus: boolean[]): number[];
  45388. /**
  45389. * Select a subsets of attachments to draw to.
  45390. * @param attachments index of attachments
  45391. */
  45392. bindAttachments(attachments: number[]): void;
  45393. /**
  45394. * Binds the frame buffer to the specified texture.
  45395. * @param texture The texture to render to or null for the default canvas
  45396. * @param faceIndex The face of the texture to render to in case of cube texture
  45397. * @param requiredWidth The width of the target to render to
  45398. * @param requiredHeight The height of the target to render to
  45399. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45400. * @param lodLevel defines the lod level to bind to the frame buffer
  45401. * @param layer defines the 2d array index to bind to frame buffer to
  45402. */
  45403. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  45404. /**
  45405. * Unbind the current render target texture from the WebGPU context
  45406. * @param texture defines the render target texture to unbind
  45407. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45408. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45409. */
  45410. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45411. /**
  45412. * Unbind a list of render target textures from the WebGPU context
  45413. * @param textures defines the render target textures to unbind
  45414. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45415. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45416. */
  45417. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45418. /**
  45419. * Unbind the current render target and bind the default framebuffer
  45420. */
  45421. restoreDefaultFramebuffer(): void;
  45422. setZOffset(value: number): void;
  45423. private _setColorFormat;
  45424. private _setDepthTextureFormat;
  45425. setDepthBuffer(enable: boolean): void;
  45426. setDepthWrite(enable: boolean): void;
  45427. setStencilBuffer(enable: boolean): void;
  45428. setStencilMask(mask: number): void;
  45429. setStencilFunction(stencilFunc: number): void;
  45430. setStencilFunctionReference(reference: number): void;
  45431. setStencilFunctionMask(mask: number): void;
  45432. setStencilOperationFail(operation: number): void;
  45433. setStencilOperationDepthFail(operation: number): void;
  45434. setStencilOperationPass(operation: number): void;
  45435. setDitheringState(value: boolean): void;
  45436. setRasterizerState(value: boolean): void;
  45437. setDepthFunction(depthFunc: number): void;
  45438. setDepthFunctionToGreater(): void;
  45439. setDepthFunctionToGreaterOrEqual(): void;
  45440. setDepthFunctionToLess(): void;
  45441. setDepthFunctionToLessOrEqual(): void;
  45442. private _indexFormatInRenderPass;
  45443. private _getTopology;
  45444. private _getOpFunction;
  45445. private _getDepthStencilStateDescriptor;
  45446. /**
  45447. * Set various states to the context
  45448. * @param culling defines backface culling state
  45449. * @param zOffset defines the value to apply to zOffset (0 by default)
  45450. * @param force defines if states must be applied even if cache is up to date
  45451. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45452. */
  45453. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45454. private _getFrontFace;
  45455. private _getCullMode;
  45456. private _getRasterizationStateDescriptor;
  45457. private _getWriteMask;
  45458. /**
  45459. * Sets the current alpha mode
  45460. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45461. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45462. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45463. */
  45464. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45465. private _getAphaBlendOperation;
  45466. private _getAphaBlendFactor;
  45467. private _getAphaBlendState;
  45468. private _getColorBlendState;
  45469. private _getColorStateDescriptors;
  45470. private _getStages;
  45471. private _getVertexInputDescriptorFormat;
  45472. private _getVertexInputDescriptor;
  45473. private _getPipelineLayout;
  45474. private _getRenderPipeline;
  45475. private _getVertexInputsToRender;
  45476. private _getBindGroupsToRender;
  45477. private _bindVertexInputs;
  45478. private _setRenderBindGroups;
  45479. private _setRenderPipeline;
  45480. /**
  45481. * Draw a list of indexed primitives
  45482. * @param fillMode defines the primitive to use
  45483. * @param indexStart defines the starting index
  45484. * @param indexCount defines the number of index to draw
  45485. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45486. */
  45487. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45488. /**
  45489. * Draw a list of unindexed primitives
  45490. * @param fillMode defines the primitive to use
  45491. * @param verticesStart defines the index of first vertex to draw
  45492. * @param verticesCount defines the count of vertices to draw
  45493. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45494. */
  45495. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45496. private _bundleEncoder;
  45497. /**
  45498. * Start recording all the gpu calls into a bundle.
  45499. */
  45500. startRecordBundle(): void;
  45501. /**
  45502. * Stops recording the bundle.
  45503. * @returns the recorded bundle
  45504. */
  45505. stopRecordBundle(): GPURenderBundle;
  45506. /**
  45507. * Execute the previously recorded bundle.
  45508. * @param bundles defines the bundle to replay
  45509. */
  45510. executeBundles(bundles: GPURenderBundle[]): void;
  45511. /**
  45512. * Dispose and release all associated resources
  45513. */
  45514. dispose(): void;
  45515. /**
  45516. * Gets the current render width
  45517. * @param useScreen defines if screen size must be used (or the current render target if any)
  45518. * @returns a number defining the current render width
  45519. */
  45520. getRenderWidth(useScreen?: boolean): number;
  45521. /**
  45522. * Gets the current render height
  45523. * @param useScreen defines if screen size must be used (or the current render target if any)
  45524. * @returns a number defining the current render height
  45525. */
  45526. getRenderHeight(useScreen?: boolean): number;
  45527. /**
  45528. * Gets the HTML canvas attached with the current WebGPU context
  45529. * @returns a HTML canvas
  45530. */
  45531. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  45532. /** @hidden */
  45533. _debugPushGroup(groupName: string, targetObject?: number): void;
  45534. /** @hidden */
  45535. _debugPopGroup(targetObject?: number): void;
  45536. /** @hidden */
  45537. _debugInsertMarker(text: string, targetObject?: number): void;
  45538. private _debugFlushPendingCommands;
  45539. /**
  45540. * Get the current error code of the WebGPU context
  45541. * @returns the error code
  45542. */
  45543. getError(): number;
  45544. /** @hidden */
  45545. bindSamplers(effect: Effect): void;
  45546. /** @hidden */
  45547. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  45548. /** @hidden */
  45549. _releaseFramebufferObjects(texture: InternalTexture): void;
  45550. /** @hidden */
  45551. applyStates(): void;
  45552. /**
  45553. * Gets a boolean indicating if all created effects are ready
  45554. * @returns always true - No parallel shader compilation
  45555. */
  45556. areAllEffectsReady(): boolean;
  45557. /** @hidden */
  45558. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45559. /** @hidden */
  45560. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45561. /** @hidden */
  45562. _getUnpackAlignement(): number;
  45563. /** @hidden */
  45564. _unpackFlipY(value: boolean): void;
  45565. /** @hidden */
  45566. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  45567. min: number;
  45568. mag: number;
  45569. };
  45570. /** @hidden */
  45571. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45572. /** @hidden */
  45573. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45574. /** @hidden */
  45575. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45576. /** @hidden */
  45577. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45578. /** @hidden */
  45579. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45580. /** @hidden */
  45581. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45582. /** @hidden */
  45583. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  45584. /** @hidden */
  45585. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  45586. /** @hidden */
  45587. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  45588. /** @hidden */
  45589. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  45590. /** @hidden */
  45591. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  45592. /** @hidden */
  45593. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45594. /** @hidden */
  45595. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45596. /** @hidden */
  45597. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  45598. /** @hidden */
  45599. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  45600. /** @hidden */
  45601. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  45602. /** @hidden */
  45603. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  45604. }
  45605. }
  45606. declare module BABYLON {
  45607. /**
  45608. * Define an interface for all classes that will hold resources
  45609. */
  45610. export interface IDisposable {
  45611. /**
  45612. * Releases all held resources
  45613. */
  45614. dispose(): void;
  45615. }
  45616. /** Interface defining initialization parameters for Scene class */
  45617. export interface SceneOptions {
  45618. /**
  45619. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  45620. * It will improve performance when the number of geometries becomes important.
  45621. */
  45622. useGeometryUniqueIdsMap?: boolean;
  45623. /**
  45624. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  45625. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45626. */
  45627. useMaterialMeshMap?: boolean;
  45628. /**
  45629. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  45630. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45631. */
  45632. useClonedMeshMap?: boolean;
  45633. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  45634. virtual?: boolean;
  45635. }
  45636. /**
  45637. * Represents a scene to be rendered by the engine.
  45638. * @see https://doc.babylonjs.com/features/scene
  45639. */
  45640. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  45641. /** The fog is deactivated */
  45642. static readonly FOGMODE_NONE: number;
  45643. /** The fog density is following an exponential function */
  45644. static readonly FOGMODE_EXP: number;
  45645. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  45646. static readonly FOGMODE_EXP2: number;
  45647. /** The fog density is following a linear function. */
  45648. static readonly FOGMODE_LINEAR: number;
  45649. /**
  45650. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  45651. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45652. */
  45653. static MinDeltaTime: number;
  45654. /**
  45655. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  45656. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45657. */
  45658. static MaxDeltaTime: number;
  45659. /**
  45660. * Factory used to create the default material.
  45661. * @param name The name of the material to create
  45662. * @param scene The scene to create the material for
  45663. * @returns The default material
  45664. */
  45665. static DefaultMaterialFactory(scene: Scene): Material;
  45666. /**
  45667. * Factory used to create the a collision coordinator.
  45668. * @returns The collision coordinator
  45669. */
  45670. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  45671. /** @hidden */
  45672. _inputManager: InputManager;
  45673. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  45674. cameraToUseForPointers: Nullable<Camera>;
  45675. /** @hidden */
  45676. readonly _isScene: boolean;
  45677. /** @hidden */
  45678. _blockEntityCollection: boolean;
  45679. /**
  45680. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  45681. */
  45682. autoClear: boolean;
  45683. /**
  45684. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  45685. */
  45686. autoClearDepthAndStencil: boolean;
  45687. /**
  45688. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  45689. */
  45690. clearColor: Color4;
  45691. /**
  45692. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  45693. */
  45694. ambientColor: Color3;
  45695. /**
  45696. * This is use to store the default BRDF lookup for PBR materials in your scene.
  45697. * It should only be one of the following (if not the default embedded one):
  45698. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45699. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  45700. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45701. * The material properties need to be setup according to the type of texture in use.
  45702. */
  45703. environmentBRDFTexture: BaseTexture;
  45704. /**
  45705. * Texture used in all pbr material as the reflection texture.
  45706. * As in the majority of the scene they are the same (exception for multi room and so on),
  45707. * this is easier to reference from here than from all the materials.
  45708. */
  45709. get environmentTexture(): Nullable<BaseTexture>;
  45710. /**
  45711. * Texture used in all pbr material as the reflection texture.
  45712. * As in the majority of the scene they are the same (exception for multi room and so on),
  45713. * this is easier to set here than in all the materials.
  45714. */
  45715. set environmentTexture(value: Nullable<BaseTexture>);
  45716. /** @hidden */
  45717. protected _environmentIntensity: number;
  45718. /**
  45719. * Intensity of the environment in all pbr material.
  45720. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45721. * As in the majority of the scene they are the same (exception for multi room and so on),
  45722. * this is easier to reference from here than from all the materials.
  45723. */
  45724. get environmentIntensity(): number;
  45725. /**
  45726. * Intensity of the environment in all pbr material.
  45727. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45728. * As in the majority of the scene they are the same (exception for multi room and so on),
  45729. * this is easier to set here than in all the materials.
  45730. */
  45731. set environmentIntensity(value: number);
  45732. /** @hidden */
  45733. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45734. /**
  45735. * Default image processing configuration used either in the rendering
  45736. * Forward main pass or through the imageProcessingPostProcess if present.
  45737. * As in the majority of the scene they are the same (exception for multi camera),
  45738. * this is easier to reference from here than from all the materials and post process.
  45739. *
  45740. * No setter as we it is a shared configuration, you can set the values instead.
  45741. */
  45742. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45743. private _forceWireframe;
  45744. /**
  45745. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  45746. */
  45747. set forceWireframe(value: boolean);
  45748. get forceWireframe(): boolean;
  45749. private _skipFrustumClipping;
  45750. /**
  45751. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  45752. */
  45753. set skipFrustumClipping(value: boolean);
  45754. get skipFrustumClipping(): boolean;
  45755. private _forcePointsCloud;
  45756. /**
  45757. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  45758. */
  45759. set forcePointsCloud(value: boolean);
  45760. get forcePointsCloud(): boolean;
  45761. /**
  45762. * Gets or sets the active clipplane 1
  45763. */
  45764. clipPlane: Nullable<Plane>;
  45765. /**
  45766. * Gets or sets the active clipplane 2
  45767. */
  45768. clipPlane2: Nullable<Plane>;
  45769. /**
  45770. * Gets or sets the active clipplane 3
  45771. */
  45772. clipPlane3: Nullable<Plane>;
  45773. /**
  45774. * Gets or sets the active clipplane 4
  45775. */
  45776. clipPlane4: Nullable<Plane>;
  45777. /**
  45778. * Gets or sets the active clipplane 5
  45779. */
  45780. clipPlane5: Nullable<Plane>;
  45781. /**
  45782. * Gets or sets the active clipplane 6
  45783. */
  45784. clipPlane6: Nullable<Plane>;
  45785. /**
  45786. * Gets or sets a boolean indicating if animations are enabled
  45787. */
  45788. animationsEnabled: boolean;
  45789. private _animationPropertiesOverride;
  45790. /**
  45791. * Gets or sets the animation properties override
  45792. */
  45793. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  45794. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  45795. /**
  45796. * Gets or sets a boolean indicating if a constant deltatime has to be used
  45797. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  45798. */
  45799. useConstantAnimationDeltaTime: boolean;
  45800. /**
  45801. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  45802. * Please note that it requires to run a ray cast through the scene on every frame
  45803. */
  45804. constantlyUpdateMeshUnderPointer: boolean;
  45805. /**
  45806. * Defines the HTML cursor to use when hovering over interactive elements
  45807. */
  45808. hoverCursor: string;
  45809. /**
  45810. * Defines the HTML default cursor to use (empty by default)
  45811. */
  45812. defaultCursor: string;
  45813. /**
  45814. * Defines whether cursors are handled by the scene.
  45815. */
  45816. doNotHandleCursors: boolean;
  45817. /**
  45818. * This is used to call preventDefault() on pointer down
  45819. * in order to block unwanted artifacts like system double clicks
  45820. */
  45821. preventDefaultOnPointerDown: boolean;
  45822. /**
  45823. * This is used to call preventDefault() on pointer up
  45824. * in order to block unwanted artifacts like system double clicks
  45825. */
  45826. preventDefaultOnPointerUp: boolean;
  45827. /**
  45828. * Gets or sets user defined metadata
  45829. */
  45830. metadata: any;
  45831. /**
  45832. * For internal use only. Please do not use.
  45833. */
  45834. reservedDataStore: any;
  45835. /**
  45836. * Gets the name of the plugin used to load this scene (null by default)
  45837. */
  45838. loadingPluginName: string;
  45839. /**
  45840. * Use this array to add regular expressions used to disable offline support for specific urls
  45841. */
  45842. disableOfflineSupportExceptionRules: RegExp[];
  45843. /**
  45844. * An event triggered when the scene is disposed.
  45845. */
  45846. onDisposeObservable: Observable<Scene>;
  45847. private _onDisposeObserver;
  45848. /** Sets a function to be executed when this scene is disposed. */
  45849. set onDispose(callback: () => void);
  45850. /**
  45851. * An event triggered before rendering the scene (right after animations and physics)
  45852. */
  45853. onBeforeRenderObservable: Observable<Scene>;
  45854. private _onBeforeRenderObserver;
  45855. /** Sets a function to be executed before rendering this scene */
  45856. set beforeRender(callback: Nullable<() => void>);
  45857. /**
  45858. * An event triggered after rendering the scene
  45859. */
  45860. onAfterRenderObservable: Observable<Scene>;
  45861. /**
  45862. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  45863. */
  45864. onAfterRenderCameraObservable: Observable<Camera>;
  45865. private _onAfterRenderObserver;
  45866. /** Sets a function to be executed after rendering this scene */
  45867. set afterRender(callback: Nullable<() => void>);
  45868. /**
  45869. * An event triggered before animating the scene
  45870. */
  45871. onBeforeAnimationsObservable: Observable<Scene>;
  45872. /**
  45873. * An event triggered after animations processing
  45874. */
  45875. onAfterAnimationsObservable: Observable<Scene>;
  45876. /**
  45877. * An event triggered before draw calls are ready to be sent
  45878. */
  45879. onBeforeDrawPhaseObservable: Observable<Scene>;
  45880. /**
  45881. * An event triggered after draw calls have been sent
  45882. */
  45883. onAfterDrawPhaseObservable: Observable<Scene>;
  45884. /**
  45885. * An event triggered when the scene is ready
  45886. */
  45887. onReadyObservable: Observable<Scene>;
  45888. /**
  45889. * An event triggered before rendering a camera
  45890. */
  45891. onBeforeCameraRenderObservable: Observable<Camera>;
  45892. private _onBeforeCameraRenderObserver;
  45893. /** Sets a function to be executed before rendering a camera*/
  45894. set beforeCameraRender(callback: () => void);
  45895. /**
  45896. * An event triggered after rendering a camera
  45897. */
  45898. onAfterCameraRenderObservable: Observable<Camera>;
  45899. private _onAfterCameraRenderObserver;
  45900. /** Sets a function to be executed after rendering a camera*/
  45901. set afterCameraRender(callback: () => void);
  45902. /**
  45903. * An event triggered when active meshes evaluation is about to start
  45904. */
  45905. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  45906. /**
  45907. * An event triggered when active meshes evaluation is done
  45908. */
  45909. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  45910. /**
  45911. * An event triggered when particles rendering is about to start
  45912. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  45913. */
  45914. onBeforeParticlesRenderingObservable: Observable<Scene>;
  45915. /**
  45916. * An event triggered when particles rendering is done
  45917. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  45918. */
  45919. onAfterParticlesRenderingObservable: Observable<Scene>;
  45920. /**
  45921. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  45922. */
  45923. onDataLoadedObservable: Observable<Scene>;
  45924. /**
  45925. * An event triggered when a camera is created
  45926. */
  45927. onNewCameraAddedObservable: Observable<Camera>;
  45928. /**
  45929. * An event triggered when a camera is removed
  45930. */
  45931. onCameraRemovedObservable: Observable<Camera>;
  45932. /**
  45933. * An event triggered when a light is created
  45934. */
  45935. onNewLightAddedObservable: Observable<Light>;
  45936. /**
  45937. * An event triggered when a light is removed
  45938. */
  45939. onLightRemovedObservable: Observable<Light>;
  45940. /**
  45941. * An event triggered when a geometry is created
  45942. */
  45943. onNewGeometryAddedObservable: Observable<Geometry>;
  45944. /**
  45945. * An event triggered when a geometry is removed
  45946. */
  45947. onGeometryRemovedObservable: Observable<Geometry>;
  45948. /**
  45949. * An event triggered when a transform node is created
  45950. */
  45951. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  45952. /**
  45953. * An event triggered when a transform node is removed
  45954. */
  45955. onTransformNodeRemovedObservable: Observable<TransformNode>;
  45956. /**
  45957. * An event triggered when a mesh is created
  45958. */
  45959. onNewMeshAddedObservable: Observable<AbstractMesh>;
  45960. /**
  45961. * An event triggered when a mesh is removed
  45962. */
  45963. onMeshRemovedObservable: Observable<AbstractMesh>;
  45964. /**
  45965. * An event triggered when a skeleton is created
  45966. */
  45967. onNewSkeletonAddedObservable: Observable<Skeleton>;
  45968. /**
  45969. * An event triggered when a skeleton is removed
  45970. */
  45971. onSkeletonRemovedObservable: Observable<Skeleton>;
  45972. /**
  45973. * An event triggered when a material is created
  45974. */
  45975. onNewMaterialAddedObservable: Observable<Material>;
  45976. /**
  45977. * An event triggered when a multi material is created
  45978. */
  45979. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  45980. /**
  45981. * An event triggered when a material is removed
  45982. */
  45983. onMaterialRemovedObservable: Observable<Material>;
  45984. /**
  45985. * An event triggered when a multi material is removed
  45986. */
  45987. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  45988. /**
  45989. * An event triggered when a texture is created
  45990. */
  45991. onNewTextureAddedObservable: Observable<BaseTexture>;
  45992. /**
  45993. * An event triggered when a texture is removed
  45994. */
  45995. onTextureRemovedObservable: Observable<BaseTexture>;
  45996. /**
  45997. * An event triggered when render targets are about to be rendered
  45998. * Can happen multiple times per frame.
  45999. */
  46000. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  46001. /**
  46002. * An event triggered when render targets were rendered.
  46003. * Can happen multiple times per frame.
  46004. */
  46005. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  46006. /**
  46007. * An event triggered before calculating deterministic simulation step
  46008. */
  46009. onBeforeStepObservable: Observable<Scene>;
  46010. /**
  46011. * An event triggered after calculating deterministic simulation step
  46012. */
  46013. onAfterStepObservable: Observable<Scene>;
  46014. /**
  46015. * An event triggered when the activeCamera property is updated
  46016. */
  46017. onActiveCameraChanged: Observable<Scene>;
  46018. /**
  46019. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  46020. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46021. * 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)
  46022. */
  46023. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46024. /**
  46025. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  46026. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46027. * 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)
  46028. */
  46029. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46030. /**
  46031. * This Observable will when a mesh has been imported into the scene.
  46032. */
  46033. onMeshImportedObservable: Observable<AbstractMesh>;
  46034. /**
  46035. * This Observable will when an animation file has been imported into the scene.
  46036. */
  46037. onAnimationFileImportedObservable: Observable<Scene>;
  46038. /**
  46039. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46040. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46041. */
  46042. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46043. /** @hidden */
  46044. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46045. /**
  46046. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46047. */
  46048. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46049. /**
  46050. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46051. */
  46052. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46053. /**
  46054. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46055. */
  46056. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46057. /** Callback called when a pointer move is detected */
  46058. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46059. /** Callback called when a pointer down is detected */
  46060. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46061. /** Callback called when a pointer up is detected */
  46062. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46063. /** Callback called when a pointer pick is detected */
  46064. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46065. /**
  46066. * 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).
  46067. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46068. */
  46069. onPrePointerObservable: Observable<PointerInfoPre>;
  46070. /**
  46071. * Observable event triggered each time an input event is received from the rendering canvas
  46072. */
  46073. onPointerObservable: Observable<PointerInfo>;
  46074. /**
  46075. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46076. */
  46077. get unTranslatedPointer(): Vector2;
  46078. /**
  46079. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46080. */
  46081. static get DragMovementThreshold(): number;
  46082. static set DragMovementThreshold(value: number);
  46083. /**
  46084. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46085. */
  46086. static get LongPressDelay(): number;
  46087. static set LongPressDelay(value: number);
  46088. /**
  46089. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46090. */
  46091. static get DoubleClickDelay(): number;
  46092. static set DoubleClickDelay(value: number);
  46093. /** If you need to check double click without raising a single click at first click, enable this flag */
  46094. static get ExclusiveDoubleClickMode(): boolean;
  46095. static set ExclusiveDoubleClickMode(value: boolean);
  46096. /** @hidden */
  46097. _mirroredCameraPosition: Nullable<Vector3>;
  46098. /**
  46099. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46100. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46101. */
  46102. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46103. /**
  46104. * Observable event triggered each time an keyboard event is received from the hosting window
  46105. */
  46106. onKeyboardObservable: Observable<KeyboardInfo>;
  46107. private _useRightHandedSystem;
  46108. /**
  46109. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46110. */
  46111. set useRightHandedSystem(value: boolean);
  46112. get useRightHandedSystem(): boolean;
  46113. private _timeAccumulator;
  46114. private _currentStepId;
  46115. private _currentInternalStep;
  46116. /**
  46117. * Sets the step Id used by deterministic lock step
  46118. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46119. * @param newStepId defines the step Id
  46120. */
  46121. setStepId(newStepId: number): void;
  46122. /**
  46123. * Gets the step Id used by deterministic lock step
  46124. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46125. * @returns the step Id
  46126. */
  46127. getStepId(): number;
  46128. /**
  46129. * Gets the internal step used by deterministic lock step
  46130. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46131. * @returns the internal step
  46132. */
  46133. getInternalStep(): number;
  46134. private _fogEnabled;
  46135. /**
  46136. * Gets or sets a boolean indicating if fog is enabled on this scene
  46137. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46138. * (Default is true)
  46139. */
  46140. set fogEnabled(value: boolean);
  46141. get fogEnabled(): boolean;
  46142. private _fogMode;
  46143. /**
  46144. * Gets or sets the fog mode to use
  46145. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46146. * | mode | value |
  46147. * | --- | --- |
  46148. * | FOGMODE_NONE | 0 |
  46149. * | FOGMODE_EXP | 1 |
  46150. * | FOGMODE_EXP2 | 2 |
  46151. * | FOGMODE_LINEAR | 3 |
  46152. */
  46153. set fogMode(value: number);
  46154. get fogMode(): number;
  46155. /**
  46156. * Gets or sets the fog color to use
  46157. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46158. * (Default is Color3(0.2, 0.2, 0.3))
  46159. */
  46160. fogColor: Color3;
  46161. /**
  46162. * Gets or sets the fog density to use
  46163. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46164. * (Default is 0.1)
  46165. */
  46166. fogDensity: number;
  46167. /**
  46168. * Gets or sets the fog start distance to use
  46169. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46170. * (Default is 0)
  46171. */
  46172. fogStart: number;
  46173. /**
  46174. * Gets or sets the fog end distance to use
  46175. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46176. * (Default is 1000)
  46177. */
  46178. fogEnd: number;
  46179. /**
  46180. * Flag indicating that the frame buffer binding is handled by another component
  46181. */
  46182. prePass: boolean;
  46183. private _shadowsEnabled;
  46184. /**
  46185. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46186. */
  46187. set shadowsEnabled(value: boolean);
  46188. get shadowsEnabled(): boolean;
  46189. private _lightsEnabled;
  46190. /**
  46191. * Gets or sets a boolean indicating if lights are enabled on this scene
  46192. */
  46193. set lightsEnabled(value: boolean);
  46194. get lightsEnabled(): boolean;
  46195. /** All of the active cameras added to this scene. */
  46196. activeCameras: Nullable<Camera[]>;
  46197. /** @hidden */
  46198. _activeCamera: Nullable<Camera>;
  46199. /** Gets or sets the current active camera */
  46200. get activeCamera(): Nullable<Camera>;
  46201. set activeCamera(value: Nullable<Camera>);
  46202. private _defaultMaterial;
  46203. /** The default material used on meshes when no material is affected */
  46204. get defaultMaterial(): Material;
  46205. /** The default material used on meshes when no material is affected */
  46206. set defaultMaterial(value: Material);
  46207. private _texturesEnabled;
  46208. /**
  46209. * Gets or sets a boolean indicating if textures are enabled on this scene
  46210. */
  46211. set texturesEnabled(value: boolean);
  46212. get texturesEnabled(): boolean;
  46213. /**
  46214. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46215. */
  46216. physicsEnabled: boolean;
  46217. /**
  46218. * Gets or sets a boolean indicating if particles are enabled on this scene
  46219. */
  46220. particlesEnabled: boolean;
  46221. /**
  46222. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46223. */
  46224. spritesEnabled: boolean;
  46225. private _skeletonsEnabled;
  46226. /**
  46227. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46228. */
  46229. set skeletonsEnabled(value: boolean);
  46230. get skeletonsEnabled(): boolean;
  46231. /**
  46232. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46233. */
  46234. lensFlaresEnabled: boolean;
  46235. /**
  46236. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46237. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46238. */
  46239. collisionsEnabled: boolean;
  46240. private _collisionCoordinator;
  46241. /** @hidden */
  46242. get collisionCoordinator(): ICollisionCoordinator;
  46243. /**
  46244. * Defines the gravity applied to this scene (used only for collisions)
  46245. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46246. */
  46247. gravity: Vector3;
  46248. /**
  46249. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46250. */
  46251. postProcessesEnabled: boolean;
  46252. /**
  46253. * Gets the current postprocess manager
  46254. */
  46255. postProcessManager: PostProcessManager;
  46256. /**
  46257. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46258. */
  46259. renderTargetsEnabled: boolean;
  46260. /**
  46261. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46262. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46263. */
  46264. dumpNextRenderTargets: boolean;
  46265. /**
  46266. * The list of user defined render targets added to the scene
  46267. */
  46268. customRenderTargets: RenderTargetTexture[];
  46269. /**
  46270. * Defines if texture loading must be delayed
  46271. * If true, textures will only be loaded when they need to be rendered
  46272. */
  46273. useDelayedTextureLoading: boolean;
  46274. /**
  46275. * Gets the list of meshes imported to the scene through SceneLoader
  46276. */
  46277. importedMeshesFiles: String[];
  46278. /**
  46279. * Gets or sets a boolean indicating if probes are enabled on this scene
  46280. */
  46281. probesEnabled: boolean;
  46282. /**
  46283. * Gets or sets the current offline provider to use to store scene data
  46284. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46285. */
  46286. offlineProvider: IOfflineProvider;
  46287. /**
  46288. * Gets or sets the action manager associated with the scene
  46289. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46290. */
  46291. actionManager: AbstractActionManager;
  46292. private _meshesForIntersections;
  46293. /**
  46294. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46295. */
  46296. proceduralTexturesEnabled: boolean;
  46297. private _engine;
  46298. private _totalVertices;
  46299. /** @hidden */
  46300. _activeIndices: PerfCounter;
  46301. /** @hidden */
  46302. _activeParticles: PerfCounter;
  46303. /** @hidden */
  46304. _activeBones: PerfCounter;
  46305. private _animationRatio;
  46306. /** @hidden */
  46307. _animationTimeLast: number;
  46308. /** @hidden */
  46309. _animationTime: number;
  46310. /**
  46311. * Gets or sets a general scale for animation speed
  46312. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46313. */
  46314. animationTimeScale: number;
  46315. /** @hidden */
  46316. _cachedMaterial: Nullable<Material>;
  46317. /** @hidden */
  46318. _cachedEffect: Nullable<Effect>;
  46319. /** @hidden */
  46320. _cachedVisibility: Nullable<number>;
  46321. private _renderId;
  46322. private _frameId;
  46323. private _executeWhenReadyTimeoutId;
  46324. private _intermediateRendering;
  46325. private _viewUpdateFlag;
  46326. private _projectionUpdateFlag;
  46327. /** @hidden */
  46328. _toBeDisposed: Nullable<IDisposable>[];
  46329. private _activeRequests;
  46330. /** @hidden */
  46331. _pendingData: any[];
  46332. private _isDisposed;
  46333. /**
  46334. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46335. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46336. */
  46337. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46338. private _activeMeshes;
  46339. private _processedMaterials;
  46340. private _renderTargets;
  46341. /** @hidden */
  46342. _activeParticleSystems: SmartArray<IParticleSystem>;
  46343. private _activeSkeletons;
  46344. private _softwareSkinnedMeshes;
  46345. private _renderingManager;
  46346. /** @hidden */
  46347. _activeAnimatables: Animatable[];
  46348. private _transformMatrix;
  46349. private _sceneUbo;
  46350. /** @hidden */
  46351. _viewMatrix: Matrix;
  46352. /** @hidden */
  46353. _projectionMatrix: Matrix;
  46354. /** @hidden */
  46355. _forcedViewPosition: Nullable<Vector3>;
  46356. /** @hidden */
  46357. _frustumPlanes: Plane[];
  46358. /**
  46359. * Gets the list of frustum planes (built from the active camera)
  46360. */
  46361. get frustumPlanes(): Plane[];
  46362. /**
  46363. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46364. * This is useful if there are more lights that the maximum simulteanous authorized
  46365. */
  46366. requireLightSorting: boolean;
  46367. /** @hidden */
  46368. readonly useMaterialMeshMap: boolean;
  46369. /** @hidden */
  46370. readonly useClonedMeshMap: boolean;
  46371. private _externalData;
  46372. private _uid;
  46373. /**
  46374. * @hidden
  46375. * Backing store of defined scene components.
  46376. */
  46377. _components: ISceneComponent[];
  46378. /**
  46379. * @hidden
  46380. * Backing store of defined scene components.
  46381. */
  46382. _serializableComponents: ISceneSerializableComponent[];
  46383. /**
  46384. * List of components to register on the next registration step.
  46385. */
  46386. private _transientComponents;
  46387. /**
  46388. * Registers the transient components if needed.
  46389. */
  46390. private _registerTransientComponents;
  46391. /**
  46392. * @hidden
  46393. * Add a component to the scene.
  46394. * Note that the ccomponent could be registered on th next frame if this is called after
  46395. * the register component stage.
  46396. * @param component Defines the component to add to the scene
  46397. */
  46398. _addComponent(component: ISceneComponent): void;
  46399. /**
  46400. * @hidden
  46401. * Gets a component from the scene.
  46402. * @param name defines the name of the component to retrieve
  46403. * @returns the component or null if not present
  46404. */
  46405. _getComponent(name: string): Nullable<ISceneComponent>;
  46406. /**
  46407. * @hidden
  46408. * Defines the actions happening before camera updates.
  46409. */
  46410. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  46411. /**
  46412. * @hidden
  46413. * Defines the actions happening before clear the canvas.
  46414. */
  46415. _beforeClearStage: Stage<SimpleStageAction>;
  46416. /**
  46417. * @hidden
  46418. * Defines the actions when collecting render targets for the frame.
  46419. */
  46420. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46421. /**
  46422. * @hidden
  46423. * Defines the actions happening for one camera in the frame.
  46424. */
  46425. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46426. /**
  46427. * @hidden
  46428. * Defines the actions happening during the per mesh ready checks.
  46429. */
  46430. _isReadyForMeshStage: Stage<MeshStageAction>;
  46431. /**
  46432. * @hidden
  46433. * Defines the actions happening before evaluate active mesh checks.
  46434. */
  46435. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  46436. /**
  46437. * @hidden
  46438. * Defines the actions happening during the evaluate sub mesh checks.
  46439. */
  46440. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  46441. /**
  46442. * @hidden
  46443. * Defines the actions happening during the active mesh stage.
  46444. */
  46445. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  46446. /**
  46447. * @hidden
  46448. * Defines the actions happening during the per camera render target step.
  46449. */
  46450. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  46451. /**
  46452. * @hidden
  46453. * Defines the actions happening just before the active camera is drawing.
  46454. */
  46455. _beforeCameraDrawStage: Stage<CameraStageAction>;
  46456. /**
  46457. * @hidden
  46458. * Defines the actions happening just before a render target is drawing.
  46459. */
  46460. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46461. /**
  46462. * @hidden
  46463. * Defines the actions happening just before a rendering group is drawing.
  46464. */
  46465. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46466. /**
  46467. * @hidden
  46468. * Defines the actions happening just before a mesh is drawing.
  46469. */
  46470. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46471. /**
  46472. * @hidden
  46473. * Defines the actions happening just after a mesh has been drawn.
  46474. */
  46475. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46476. /**
  46477. * @hidden
  46478. * Defines the actions happening just after a rendering group has been drawn.
  46479. */
  46480. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46481. /**
  46482. * @hidden
  46483. * Defines the actions happening just after the active camera has been drawn.
  46484. */
  46485. _afterCameraDrawStage: Stage<CameraStageAction>;
  46486. /**
  46487. * @hidden
  46488. * Defines the actions happening just after a render target has been drawn.
  46489. */
  46490. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46491. /**
  46492. * @hidden
  46493. * Defines the actions happening just after rendering all cameras and computing intersections.
  46494. */
  46495. _afterRenderStage: Stage<SimpleStageAction>;
  46496. /**
  46497. * @hidden
  46498. * Defines the actions happening when a pointer move event happens.
  46499. */
  46500. _pointerMoveStage: Stage<PointerMoveStageAction>;
  46501. /**
  46502. * @hidden
  46503. * Defines the actions happening when a pointer down event happens.
  46504. */
  46505. _pointerDownStage: Stage<PointerUpDownStageAction>;
  46506. /**
  46507. * @hidden
  46508. * Defines the actions happening when a pointer up event happens.
  46509. */
  46510. _pointerUpStage: Stage<PointerUpDownStageAction>;
  46511. /**
  46512. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  46513. */
  46514. private geometriesByUniqueId;
  46515. private _renderBundles;
  46516. /**
  46517. * Creates a new Scene
  46518. * @param engine defines the engine to use to render this scene
  46519. * @param options defines the scene options
  46520. */
  46521. constructor(engine: Engine, options?: SceneOptions);
  46522. /**
  46523. * Gets a string identifying the name of the class
  46524. * @returns "Scene" string
  46525. */
  46526. getClassName(): string;
  46527. private _defaultMeshCandidates;
  46528. /**
  46529. * @hidden
  46530. */
  46531. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46532. private _defaultSubMeshCandidates;
  46533. /**
  46534. * @hidden
  46535. */
  46536. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46537. /**
  46538. * Sets the default candidate providers for the scene.
  46539. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  46540. * and getCollidingSubMeshCandidates to their default function
  46541. */
  46542. setDefaultCandidateProviders(): void;
  46543. /**
  46544. * Gets the mesh that is currently under the pointer
  46545. */
  46546. get meshUnderPointer(): Nullable<AbstractMesh>;
  46547. /**
  46548. * Gets or sets the current on-screen X position of the pointer
  46549. */
  46550. get pointerX(): number;
  46551. set pointerX(value: number);
  46552. /**
  46553. * Gets or sets the current on-screen Y position of the pointer
  46554. */
  46555. get pointerY(): number;
  46556. set pointerY(value: number);
  46557. /**
  46558. * Gets the cached material (ie. the latest rendered one)
  46559. * @returns the cached material
  46560. */
  46561. getCachedMaterial(): Nullable<Material>;
  46562. /**
  46563. * Gets the cached effect (ie. the latest rendered one)
  46564. * @returns the cached effect
  46565. */
  46566. getCachedEffect(): Nullable<Effect>;
  46567. /**
  46568. * Gets the cached visibility state (ie. the latest rendered one)
  46569. * @returns the cached visibility state
  46570. */
  46571. getCachedVisibility(): Nullable<number>;
  46572. /**
  46573. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  46574. * @param material defines the current material
  46575. * @param effect defines the current effect
  46576. * @param visibility defines the current visibility state
  46577. * @returns true if one parameter is not cached
  46578. */
  46579. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  46580. /**
  46581. * Gets the engine associated with the scene
  46582. * @returns an Engine
  46583. */
  46584. getEngine(): Engine;
  46585. /**
  46586. * Gets the total number of vertices rendered per frame
  46587. * @returns the total number of vertices rendered per frame
  46588. */
  46589. getTotalVertices(): number;
  46590. /**
  46591. * Gets the performance counter for total vertices
  46592. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46593. */
  46594. get totalVerticesPerfCounter(): PerfCounter;
  46595. /**
  46596. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  46597. * @returns the total number of active indices rendered per frame
  46598. */
  46599. getActiveIndices(): number;
  46600. /**
  46601. * Gets the performance counter for active indices
  46602. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46603. */
  46604. get totalActiveIndicesPerfCounter(): PerfCounter;
  46605. /**
  46606. * Gets the total number of active particles rendered per frame
  46607. * @returns the total number of active particles rendered per frame
  46608. */
  46609. getActiveParticles(): number;
  46610. /**
  46611. * Gets the performance counter for active particles
  46612. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46613. */
  46614. get activeParticlesPerfCounter(): PerfCounter;
  46615. /**
  46616. * Gets the total number of active bones rendered per frame
  46617. * @returns the total number of active bones rendered per frame
  46618. */
  46619. getActiveBones(): number;
  46620. /**
  46621. * Gets the performance counter for active bones
  46622. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46623. */
  46624. get activeBonesPerfCounter(): PerfCounter;
  46625. /**
  46626. * Gets the array of active meshes
  46627. * @returns an array of AbstractMesh
  46628. */
  46629. getActiveMeshes(): SmartArray<AbstractMesh>;
  46630. /**
  46631. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  46632. * @returns a number
  46633. */
  46634. getAnimationRatio(): number;
  46635. /**
  46636. * Gets an unique Id for the current render phase
  46637. * @returns a number
  46638. */
  46639. getRenderId(): number;
  46640. /**
  46641. * Gets an unique Id for the current frame
  46642. * @returns a number
  46643. */
  46644. getFrameId(): number;
  46645. /** Call this function if you want to manually increment the render Id*/
  46646. incrementRenderId(): void;
  46647. private _createUbo;
  46648. /**
  46649. * Use this method to simulate a pointer move on a mesh
  46650. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46651. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46652. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46653. * @returns the current scene
  46654. */
  46655. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46656. /**
  46657. * Use this method to simulate a pointer down on a mesh
  46658. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46659. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46660. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46661. * @returns the current scene
  46662. */
  46663. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46664. /**
  46665. * Use this method to simulate a pointer up on a mesh
  46666. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46667. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46668. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46669. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  46670. * @returns the current scene
  46671. */
  46672. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  46673. /**
  46674. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  46675. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  46676. * @returns true if the pointer was captured
  46677. */
  46678. isPointerCaptured(pointerId?: number): boolean;
  46679. /**
  46680. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  46681. * @param attachUp defines if you want to attach events to pointerup
  46682. * @param attachDown defines if you want to attach events to pointerdown
  46683. * @param attachMove defines if you want to attach events to pointermove
  46684. */
  46685. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  46686. /** Detaches all event handlers*/
  46687. detachControl(): void;
  46688. /**
  46689. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  46690. * Delay loaded resources are not taking in account
  46691. * @return true if all required resources are ready
  46692. */
  46693. isReady(): boolean;
  46694. /** Resets all cached information relative to material (including effect and visibility) */
  46695. resetCachedMaterial(): void;
  46696. /**
  46697. * Registers a function to be called before every frame render
  46698. * @param func defines the function to register
  46699. */
  46700. registerBeforeRender(func: () => void): void;
  46701. /**
  46702. * Unregisters a function called before every frame render
  46703. * @param func defines the function to unregister
  46704. */
  46705. unregisterBeforeRender(func: () => void): void;
  46706. /**
  46707. * Registers a function to be called after every frame render
  46708. * @param func defines the function to register
  46709. */
  46710. registerAfterRender(func: () => void): void;
  46711. /**
  46712. * Unregisters a function called after every frame render
  46713. * @param func defines the function to unregister
  46714. */
  46715. unregisterAfterRender(func: () => void): void;
  46716. private _executeOnceBeforeRender;
  46717. /**
  46718. * The provided function will run before render once and will be disposed afterwards.
  46719. * A timeout delay can be provided so that the function will be executed in N ms.
  46720. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  46721. * @param func The function to be executed.
  46722. * @param timeout optional delay in ms
  46723. */
  46724. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  46725. /** @hidden */
  46726. _addPendingData(data: any): void;
  46727. /** @hidden */
  46728. _removePendingData(data: any): void;
  46729. /**
  46730. * Returns the number of items waiting to be loaded
  46731. * @returns the number of items waiting to be loaded
  46732. */
  46733. getWaitingItemsCount(): number;
  46734. /**
  46735. * Returns a boolean indicating if the scene is still loading data
  46736. */
  46737. get isLoading(): boolean;
  46738. /**
  46739. * Registers a function to be executed when the scene is ready
  46740. * @param {Function} func - the function to be executed
  46741. */
  46742. executeWhenReady(func: () => void): void;
  46743. /**
  46744. * Returns a promise that resolves when the scene is ready
  46745. * @returns A promise that resolves when the scene is ready
  46746. */
  46747. whenReadyAsync(): Promise<void>;
  46748. /** @hidden */
  46749. _checkIsReady(): void;
  46750. /**
  46751. * Gets all animatable attached to the scene
  46752. */
  46753. get animatables(): Animatable[];
  46754. /**
  46755. * Resets the last animation time frame.
  46756. * Useful to override when animations start running when loading a scene for the first time.
  46757. */
  46758. resetLastAnimationTimeFrame(): void;
  46759. /**
  46760. * Gets the current view matrix
  46761. * @returns a Matrix
  46762. */
  46763. getViewMatrix(): Matrix;
  46764. /**
  46765. * Gets the current projection matrix
  46766. * @returns a Matrix
  46767. */
  46768. getProjectionMatrix(): Matrix;
  46769. /**
  46770. * Gets the current transform matrix
  46771. * @returns a Matrix made of View * Projection
  46772. */
  46773. getTransformMatrix(): Matrix;
  46774. /**
  46775. * Sets the current transform matrix
  46776. * @param viewL defines the View matrix to use
  46777. * @param projectionL defines the Projection matrix to use
  46778. * @param viewR defines the right View matrix to use (if provided)
  46779. * @param projectionR defines the right Projection matrix to use (if provided)
  46780. */
  46781. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  46782. /**
  46783. * Gets the uniform buffer used to store scene data
  46784. * @returns a UniformBuffer
  46785. */
  46786. getSceneUniformBuffer(): UniformBuffer;
  46787. /**
  46788. * Gets an unique (relatively to the current scene) Id
  46789. * @returns an unique number for the scene
  46790. */
  46791. getUniqueId(): number;
  46792. /**
  46793. * Add a mesh to the list of scene's meshes
  46794. * @param newMesh defines the mesh to add
  46795. * @param recursive if all child meshes should also be added to the scene
  46796. */
  46797. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  46798. /**
  46799. * Remove a mesh for the list of scene's meshes
  46800. * @param toRemove defines the mesh to remove
  46801. * @param recursive if all child meshes should also be removed from the scene
  46802. * @returns the index where the mesh was in the mesh list
  46803. */
  46804. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  46805. /**
  46806. * Add a transform node to the list of scene's transform nodes
  46807. * @param newTransformNode defines the transform node to add
  46808. */
  46809. addTransformNode(newTransformNode: TransformNode): void;
  46810. /**
  46811. * Remove a transform node for the list of scene's transform nodes
  46812. * @param toRemove defines the transform node to remove
  46813. * @returns the index where the transform node was in the transform node list
  46814. */
  46815. removeTransformNode(toRemove: TransformNode): number;
  46816. /**
  46817. * Remove a skeleton for the list of scene's skeletons
  46818. * @param toRemove defines the skeleton to remove
  46819. * @returns the index where the skeleton was in the skeleton list
  46820. */
  46821. removeSkeleton(toRemove: Skeleton): number;
  46822. /**
  46823. * Remove a morph target for the list of scene's morph targets
  46824. * @param toRemove defines the morph target to remove
  46825. * @returns the index where the morph target was in the morph target list
  46826. */
  46827. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  46828. /**
  46829. * Remove a light for the list of scene's lights
  46830. * @param toRemove defines the light to remove
  46831. * @returns the index where the light was in the light list
  46832. */
  46833. removeLight(toRemove: Light): number;
  46834. /**
  46835. * Remove a camera for the list of scene's cameras
  46836. * @param toRemove defines the camera to remove
  46837. * @returns the index where the camera was in the camera list
  46838. */
  46839. removeCamera(toRemove: Camera): number;
  46840. /**
  46841. * Remove a particle system for the list of scene's particle systems
  46842. * @param toRemove defines the particle system to remove
  46843. * @returns the index where the particle system was in the particle system list
  46844. */
  46845. removeParticleSystem(toRemove: IParticleSystem): number;
  46846. /**
  46847. * Remove a animation for the list of scene's animations
  46848. * @param toRemove defines the animation to remove
  46849. * @returns the index where the animation was in the animation list
  46850. */
  46851. removeAnimation(toRemove: Animation): number;
  46852. /**
  46853. * Will stop the animation of the given target
  46854. * @param target - the target
  46855. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  46856. * @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)
  46857. */
  46858. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  46859. /**
  46860. * Removes the given animation group from this scene.
  46861. * @param toRemove The animation group to remove
  46862. * @returns The index of the removed animation group
  46863. */
  46864. removeAnimationGroup(toRemove: AnimationGroup): number;
  46865. /**
  46866. * Removes the given multi-material from this scene.
  46867. * @param toRemove The multi-material to remove
  46868. * @returns The index of the removed multi-material
  46869. */
  46870. removeMultiMaterial(toRemove: MultiMaterial): number;
  46871. /**
  46872. * Removes the given material from this scene.
  46873. * @param toRemove The material to remove
  46874. * @returns The index of the removed material
  46875. */
  46876. removeMaterial(toRemove: Material): number;
  46877. /**
  46878. * Removes the given action manager from this scene.
  46879. * @param toRemove The action manager to remove
  46880. * @returns The index of the removed action manager
  46881. */
  46882. removeActionManager(toRemove: AbstractActionManager): number;
  46883. /**
  46884. * Removes the given texture from this scene.
  46885. * @param toRemove The texture to remove
  46886. * @returns The index of the removed texture
  46887. */
  46888. removeTexture(toRemove: BaseTexture): number;
  46889. /**
  46890. * Adds the given light to this scene
  46891. * @param newLight The light to add
  46892. */
  46893. addLight(newLight: Light): void;
  46894. /**
  46895. * Sorts the list list based on light priorities
  46896. */
  46897. sortLightsByPriority(): void;
  46898. /**
  46899. * Adds the given camera to this scene
  46900. * @param newCamera The camera to add
  46901. */
  46902. addCamera(newCamera: Camera): void;
  46903. /**
  46904. * Adds the given skeleton to this scene
  46905. * @param newSkeleton The skeleton to add
  46906. */
  46907. addSkeleton(newSkeleton: Skeleton): void;
  46908. /**
  46909. * Adds the given particle system to this scene
  46910. * @param newParticleSystem The particle system to add
  46911. */
  46912. addParticleSystem(newParticleSystem: IParticleSystem): void;
  46913. /**
  46914. * Adds the given animation to this scene
  46915. * @param newAnimation The animation to add
  46916. */
  46917. addAnimation(newAnimation: Animation): void;
  46918. /**
  46919. * Adds the given animation group to this scene.
  46920. * @param newAnimationGroup The animation group to add
  46921. */
  46922. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  46923. /**
  46924. * Adds the given multi-material to this scene
  46925. * @param newMultiMaterial The multi-material to add
  46926. */
  46927. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  46928. /**
  46929. * Adds the given material to this scene
  46930. * @param newMaterial The material to add
  46931. */
  46932. addMaterial(newMaterial: Material): void;
  46933. /**
  46934. * Adds the given morph target to this scene
  46935. * @param newMorphTargetManager The morph target to add
  46936. */
  46937. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  46938. /**
  46939. * Adds the given geometry to this scene
  46940. * @param newGeometry The geometry to add
  46941. */
  46942. addGeometry(newGeometry: Geometry): void;
  46943. /**
  46944. * Adds the given action manager to this scene
  46945. * @param newActionManager The action manager to add
  46946. */
  46947. addActionManager(newActionManager: AbstractActionManager): void;
  46948. /**
  46949. * Adds the given texture to this scene.
  46950. * @param newTexture The texture to add
  46951. */
  46952. addTexture(newTexture: BaseTexture): void;
  46953. /**
  46954. * Switch active camera
  46955. * @param newCamera defines the new active camera
  46956. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  46957. */
  46958. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  46959. /**
  46960. * sets the active camera of the scene using its ID
  46961. * @param id defines the camera's ID
  46962. * @return the new active camera or null if none found.
  46963. */
  46964. setActiveCameraByID(id: string): Nullable<Camera>;
  46965. /**
  46966. * sets the active camera of the scene using its name
  46967. * @param name defines the camera's name
  46968. * @returns the new active camera or null if none found.
  46969. */
  46970. setActiveCameraByName(name: string): Nullable<Camera>;
  46971. /**
  46972. * get an animation group using its name
  46973. * @param name defines the material's name
  46974. * @return the animation group or null if none found.
  46975. */
  46976. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  46977. /**
  46978. * Get a material using its unique id
  46979. * @param uniqueId defines the material's unique id
  46980. * @return the material or null if none found.
  46981. */
  46982. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  46983. /**
  46984. * get a material using its id
  46985. * @param id defines the material's ID
  46986. * @return the material or null if none found.
  46987. */
  46988. getMaterialByID(id: string): Nullable<Material>;
  46989. /**
  46990. * Gets a the last added material using a given id
  46991. * @param id defines the material's ID
  46992. * @return the last material with the given id or null if none found.
  46993. */
  46994. getLastMaterialByID(id: string): Nullable<Material>;
  46995. /**
  46996. * Gets a material using its name
  46997. * @param name defines the material's name
  46998. * @return the material or null if none found.
  46999. */
  47000. getMaterialByName(name: string): Nullable<Material>;
  47001. /**
  47002. * Get a texture using its unique id
  47003. * @param uniqueId defines the texture's unique id
  47004. * @return the texture or null if none found.
  47005. */
  47006. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  47007. /**
  47008. * Gets a camera using its id
  47009. * @param id defines the id to look for
  47010. * @returns the camera or null if not found
  47011. */
  47012. getCameraByID(id: string): Nullable<Camera>;
  47013. /**
  47014. * Gets a camera using its unique id
  47015. * @param uniqueId defines the unique id to look for
  47016. * @returns the camera or null if not found
  47017. */
  47018. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  47019. /**
  47020. * Gets a camera using its name
  47021. * @param name defines the camera's name
  47022. * @return the camera or null if none found.
  47023. */
  47024. getCameraByName(name: string): Nullable<Camera>;
  47025. /**
  47026. * Gets a bone using its id
  47027. * @param id defines the bone's id
  47028. * @return the bone or null if not found
  47029. */
  47030. getBoneByID(id: string): Nullable<Bone>;
  47031. /**
  47032. * Gets a bone using its id
  47033. * @param name defines the bone's name
  47034. * @return the bone or null if not found
  47035. */
  47036. getBoneByName(name: string): Nullable<Bone>;
  47037. /**
  47038. * Gets a light node using its name
  47039. * @param name defines the the light's name
  47040. * @return the light or null if none found.
  47041. */
  47042. getLightByName(name: string): Nullable<Light>;
  47043. /**
  47044. * Gets a light node using its id
  47045. * @param id defines the light's id
  47046. * @return the light or null if none found.
  47047. */
  47048. getLightByID(id: string): Nullable<Light>;
  47049. /**
  47050. * Gets a light node using its scene-generated unique ID
  47051. * @param uniqueId defines the light's unique id
  47052. * @return the light or null if none found.
  47053. */
  47054. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47055. /**
  47056. * Gets a particle system by id
  47057. * @param id defines the particle system id
  47058. * @return the corresponding system or null if none found
  47059. */
  47060. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47061. /**
  47062. * Gets a geometry using its ID
  47063. * @param id defines the geometry's id
  47064. * @return the geometry or null if none found.
  47065. */
  47066. getGeometryByID(id: string): Nullable<Geometry>;
  47067. private _getGeometryByUniqueID;
  47068. /**
  47069. * Add a new geometry to this scene
  47070. * @param geometry defines the geometry to be added to the scene.
  47071. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47072. * @return a boolean defining if the geometry was added or not
  47073. */
  47074. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47075. /**
  47076. * Removes an existing geometry
  47077. * @param geometry defines the geometry to be removed from the scene
  47078. * @return a boolean defining if the geometry was removed or not
  47079. */
  47080. removeGeometry(geometry: Geometry): boolean;
  47081. /**
  47082. * Gets the list of geometries attached to the scene
  47083. * @returns an array of Geometry
  47084. */
  47085. getGeometries(): Geometry[];
  47086. /**
  47087. * Gets the first added mesh found of a given ID
  47088. * @param id defines the id to search for
  47089. * @return the mesh found or null if not found at all
  47090. */
  47091. getMeshByID(id: string): Nullable<AbstractMesh>;
  47092. /**
  47093. * Gets a list of meshes using their id
  47094. * @param id defines the id to search for
  47095. * @returns a list of meshes
  47096. */
  47097. getMeshesByID(id: string): Array<AbstractMesh>;
  47098. /**
  47099. * Gets the first added transform node found of a given ID
  47100. * @param id defines the id to search for
  47101. * @return the found transform node or null if not found at all.
  47102. */
  47103. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47104. /**
  47105. * Gets a transform node with its auto-generated unique id
  47106. * @param uniqueId efines the unique id to search for
  47107. * @return the found transform node or null if not found at all.
  47108. */
  47109. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47110. /**
  47111. * Gets a list of transform nodes using their id
  47112. * @param id defines the id to search for
  47113. * @returns a list of transform nodes
  47114. */
  47115. getTransformNodesByID(id: string): Array<TransformNode>;
  47116. /**
  47117. * Gets a mesh with its auto-generated unique id
  47118. * @param uniqueId defines the unique id to search for
  47119. * @return the found mesh or null if not found at all.
  47120. */
  47121. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47122. /**
  47123. * Gets a the last added mesh using a given id
  47124. * @param id defines the id to search for
  47125. * @return the found mesh or null if not found at all.
  47126. */
  47127. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47128. /**
  47129. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47130. * @param id defines the id to search for
  47131. * @return the found node or null if not found at all
  47132. */
  47133. getLastEntryByID(id: string): Nullable<Node>;
  47134. /**
  47135. * Gets a node (Mesh, Camera, Light) using a given id
  47136. * @param id defines the id to search for
  47137. * @return the found node or null if not found at all
  47138. */
  47139. getNodeByID(id: string): Nullable<Node>;
  47140. /**
  47141. * Gets a node (Mesh, Camera, Light) using a given name
  47142. * @param name defines the name to search for
  47143. * @return the found node or null if not found at all.
  47144. */
  47145. getNodeByName(name: string): Nullable<Node>;
  47146. /**
  47147. * Gets a mesh using a given name
  47148. * @param name defines the name to search for
  47149. * @return the found mesh or null if not found at all.
  47150. */
  47151. getMeshByName(name: string): Nullable<AbstractMesh>;
  47152. /**
  47153. * Gets a transform node using a given name
  47154. * @param name defines the name to search for
  47155. * @return the found transform node or null if not found at all.
  47156. */
  47157. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47158. /**
  47159. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47160. * @param id defines the id to search for
  47161. * @return the found skeleton or null if not found at all.
  47162. */
  47163. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47164. /**
  47165. * Gets a skeleton using a given auto generated unique id
  47166. * @param uniqueId defines the unique id to search for
  47167. * @return the found skeleton or null if not found at all.
  47168. */
  47169. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47170. /**
  47171. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47172. * @param id defines the id to search for
  47173. * @return the found skeleton or null if not found at all.
  47174. */
  47175. getSkeletonById(id: string): Nullable<Skeleton>;
  47176. /**
  47177. * Gets a skeleton using a given name
  47178. * @param name defines the name to search for
  47179. * @return the found skeleton or null if not found at all.
  47180. */
  47181. getSkeletonByName(name: string): Nullable<Skeleton>;
  47182. /**
  47183. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47184. * @param id defines the id to search for
  47185. * @return the found morph target manager or null if not found at all.
  47186. */
  47187. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47188. /**
  47189. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47190. * @param id defines the id to search for
  47191. * @return the found morph target or null if not found at all.
  47192. */
  47193. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47194. /**
  47195. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47196. * @param name defines the name to search for
  47197. * @return the found morph target or null if not found at all.
  47198. */
  47199. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47200. /**
  47201. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47202. * @param name defines the name to search for
  47203. * @return the found post process or null if not found at all.
  47204. */
  47205. getPostProcessByName(name: string): Nullable<PostProcess>;
  47206. /**
  47207. * Gets a boolean indicating if the given mesh is active
  47208. * @param mesh defines the mesh to look for
  47209. * @returns true if the mesh is in the active list
  47210. */
  47211. isActiveMesh(mesh: AbstractMesh): boolean;
  47212. /**
  47213. * Return a unique id as a string which can serve as an identifier for the scene
  47214. */
  47215. get uid(): string;
  47216. /**
  47217. * Add an externaly attached data from its key.
  47218. * This method call will fail and return false, if such key already exists.
  47219. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47220. * @param key the unique key that identifies the data
  47221. * @param data the data object to associate to the key for this Engine instance
  47222. * @return true if no such key were already present and the data was added successfully, false otherwise
  47223. */
  47224. addExternalData<T>(key: string, data: T): boolean;
  47225. /**
  47226. * Get an externaly attached data from its key
  47227. * @param key the unique key that identifies the data
  47228. * @return the associated data, if present (can be null), or undefined if not present
  47229. */
  47230. getExternalData<T>(key: string): Nullable<T>;
  47231. /**
  47232. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47233. * @param key the unique key that identifies the data
  47234. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47235. * @return the associated data, can be null if the factory returned null.
  47236. */
  47237. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47238. /**
  47239. * Remove an externaly attached data from the Engine instance
  47240. * @param key the unique key that identifies the data
  47241. * @return true if the data was successfully removed, false if it doesn't exist
  47242. */
  47243. removeExternalData(key: string): boolean;
  47244. private _evaluateSubMesh;
  47245. /**
  47246. * Clear the processed materials smart array preventing retention point in material dispose.
  47247. */
  47248. freeProcessedMaterials(): void;
  47249. private _preventFreeActiveMeshesAndRenderingGroups;
  47250. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47251. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47252. * when disposing several meshes in a row or a hierarchy of meshes.
  47253. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47254. */
  47255. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47256. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47257. /**
  47258. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47259. */
  47260. freeActiveMeshes(): void;
  47261. /**
  47262. * Clear the info related to rendering groups preventing retention points during dispose.
  47263. */
  47264. freeRenderingGroups(): void;
  47265. /** @hidden */
  47266. _isInIntermediateRendering(): boolean;
  47267. /**
  47268. * Lambda returning the list of potentially active meshes.
  47269. */
  47270. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47271. /**
  47272. * Lambda returning the list of potentially active sub meshes.
  47273. */
  47274. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47275. /**
  47276. * Lambda returning the list of potentially intersecting sub meshes.
  47277. */
  47278. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47279. /**
  47280. * Lambda returning the list of potentially colliding sub meshes.
  47281. */
  47282. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47283. /** @hidden */
  47284. _activeMeshesFrozen: boolean;
  47285. private _skipEvaluateActiveMeshesCompletely;
  47286. /**
  47287. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47288. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47289. * @param onSuccess optional success callback
  47290. * @param onError optional error callback
  47291. * @returns the current scene
  47292. */
  47293. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47294. /**
  47295. * Use this function to restart evaluating active meshes on every frame
  47296. * @returns the current scene
  47297. */
  47298. unfreezeActiveMeshes(): Scene;
  47299. private _evaluateActiveMeshes;
  47300. private _activeMesh;
  47301. /**
  47302. * Update the transform matrix to update from the current active camera
  47303. * @param force defines a boolean used to force the update even if cache is up to date
  47304. */
  47305. updateTransformMatrix(force?: boolean): void;
  47306. private _bindFrameBuffer;
  47307. /** @hidden */
  47308. _allowPostProcessClearColor: boolean;
  47309. /** @hidden */
  47310. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47311. private _processSubCameras;
  47312. private _checkIntersections;
  47313. /** @hidden */
  47314. _advancePhysicsEngineStep(step: number): void;
  47315. /**
  47316. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47317. */
  47318. getDeterministicFrameTime: () => number;
  47319. /** @hidden */
  47320. _animate(): void;
  47321. /** Execute all animations (for a frame) */
  47322. animate(): void;
  47323. /**
  47324. * Render the scene
  47325. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47326. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47327. */
  47328. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47329. /**
  47330. * Freeze all materials
  47331. * A frozen material will not be updatable but should be faster to render
  47332. */
  47333. freezeMaterials(): void;
  47334. /**
  47335. * Unfreeze all materials
  47336. * A frozen material will not be updatable but should be faster to render
  47337. */
  47338. unfreezeMaterials(): void;
  47339. /**
  47340. * Releases all held ressources
  47341. */
  47342. dispose(): void;
  47343. /**
  47344. * Gets if the scene is already disposed
  47345. */
  47346. get isDisposed(): boolean;
  47347. /**
  47348. * Call this function to reduce memory footprint of the scene.
  47349. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47350. */
  47351. clearCachedVertexData(): void;
  47352. /**
  47353. * This function will remove the local cached buffer data from texture.
  47354. * It will save memory but will prevent the texture from being rebuilt
  47355. */
  47356. cleanCachedTextureBuffer(): void;
  47357. /**
  47358. * Get the world extend vectors with an optional filter
  47359. *
  47360. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47361. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47362. */
  47363. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47364. min: Vector3;
  47365. max: Vector3;
  47366. };
  47367. /**
  47368. * Creates a ray that can be used to pick in the scene
  47369. * @param x defines the x coordinate of the origin (on-screen)
  47370. * @param y defines the y coordinate of the origin (on-screen)
  47371. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47372. * @param camera defines the camera to use for the picking
  47373. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47374. * @returns a Ray
  47375. */
  47376. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  47377. /**
  47378. * Creates a ray that can be used to pick in the scene
  47379. * @param x defines the x coordinate of the origin (on-screen)
  47380. * @param y defines the y coordinate of the origin (on-screen)
  47381. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47382. * @param result defines the ray where to store the picking ray
  47383. * @param camera defines the camera to use for the picking
  47384. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47385. * @returns the current scene
  47386. */
  47387. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  47388. /**
  47389. * Creates a ray that can be used to pick in the scene
  47390. * @param x defines the x coordinate of the origin (on-screen)
  47391. * @param y defines the y coordinate of the origin (on-screen)
  47392. * @param camera defines the camera to use for the picking
  47393. * @returns a Ray
  47394. */
  47395. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  47396. /**
  47397. * Creates a ray that can be used to pick in the scene
  47398. * @param x defines the x coordinate of the origin (on-screen)
  47399. * @param y defines the y coordinate of the origin (on-screen)
  47400. * @param result defines the ray where to store the picking ray
  47401. * @param camera defines the camera to use for the picking
  47402. * @returns the current scene
  47403. */
  47404. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  47405. /** Launch a ray to try to pick a mesh in the scene
  47406. * @param x position on screen
  47407. * @param y position on screen
  47408. * @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
  47409. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47410. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47411. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47412. * @returns a PickingInfo
  47413. */
  47414. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47415. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  47416. * @param x position on screen
  47417. * @param y position on screen
  47418. * @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
  47419. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47420. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47421. * @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)
  47422. */
  47423. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  47424. /** Use the given ray to pick a mesh in the scene
  47425. * @param ray The ray to use to pick meshes
  47426. * @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
  47427. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47428. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47429. * @returns a PickingInfo
  47430. */
  47431. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47432. /**
  47433. * Launch a ray to try to pick a mesh in the scene
  47434. * @param x X position on screen
  47435. * @param y Y position on screen
  47436. * @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
  47437. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47438. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47439. * @returns an array of PickingInfo
  47440. */
  47441. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47442. /**
  47443. * Launch a ray to try to pick a mesh in the scene
  47444. * @param ray Ray to use
  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 trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47447. * @returns an array of PickingInfo
  47448. */
  47449. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47450. /**
  47451. * Force the value of meshUnderPointer
  47452. * @param mesh defines the mesh to use
  47453. * @param pointerId optional pointer id when using more than one pointer
  47454. */
  47455. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  47456. /**
  47457. * Gets the mesh under the pointer
  47458. * @returns a Mesh or null if no mesh is under the pointer
  47459. */
  47460. getPointerOverMesh(): Nullable<AbstractMesh>;
  47461. /** @hidden */
  47462. _rebuildGeometries(): void;
  47463. /** @hidden */
  47464. _rebuildTextures(): void;
  47465. private _getByTags;
  47466. /**
  47467. * Get a list of meshes by tags
  47468. * @param tagsQuery defines the tags query to use
  47469. * @param forEach defines a predicate used to filter results
  47470. * @returns an array of Mesh
  47471. */
  47472. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  47473. /**
  47474. * Get a list of cameras by tags
  47475. * @param tagsQuery defines the tags query to use
  47476. * @param forEach defines a predicate used to filter results
  47477. * @returns an array of Camera
  47478. */
  47479. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  47480. /**
  47481. * Get a list of lights by tags
  47482. * @param tagsQuery defines the tags query to use
  47483. * @param forEach defines a predicate used to filter results
  47484. * @returns an array of Light
  47485. */
  47486. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  47487. /**
  47488. * Get a list of materials by tags
  47489. * @param tagsQuery defines the tags query to use
  47490. * @param forEach defines a predicate used to filter results
  47491. * @returns an array of Material
  47492. */
  47493. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  47494. /**
  47495. * Get a list of transform nodes by tags
  47496. * @param tagsQuery defines the tags query to use
  47497. * @param forEach defines a predicate used to filter results
  47498. * @returns an array of TransformNode
  47499. */
  47500. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  47501. /**
  47502. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47503. * This allowed control for front to back rendering or reversly depending of the special needs.
  47504. *
  47505. * @param renderingGroupId The rendering group id corresponding to its index
  47506. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47507. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47508. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47509. */
  47510. 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;
  47511. /**
  47512. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47513. *
  47514. * @param renderingGroupId The rendering group id corresponding to its index
  47515. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47516. * @param depth Automatically clears depth between groups if true and autoClear is true.
  47517. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  47518. */
  47519. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  47520. /**
  47521. * Gets the current auto clear configuration for one rendering group of the rendering
  47522. * manager.
  47523. * @param index the rendering group index to get the information for
  47524. * @returns The auto clear setup for the requested rendering group
  47525. */
  47526. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  47527. private _blockMaterialDirtyMechanism;
  47528. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  47529. get blockMaterialDirtyMechanism(): boolean;
  47530. set blockMaterialDirtyMechanism(value: boolean);
  47531. /**
  47532. * Will flag all materials as dirty to trigger new shader compilation
  47533. * @param flag defines the flag used to specify which material part must be marked as dirty
  47534. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  47535. */
  47536. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  47537. /** @hidden */
  47538. _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;
  47539. /** @hidden */
  47540. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47541. /** @hidden */
  47542. _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;
  47543. /** @hidden */
  47544. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  47545. /** @hidden */
  47546. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  47547. /** @hidden */
  47548. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47549. }
  47550. }
  47551. declare module BABYLON {
  47552. /**
  47553. * Set of assets to keep when moving a scene into an asset container.
  47554. */
  47555. export class KeepAssets extends AbstractScene {
  47556. }
  47557. /**
  47558. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  47559. */
  47560. export class InstantiatedEntries {
  47561. /**
  47562. * List of new root nodes (eg. nodes with no parent)
  47563. */
  47564. rootNodes: TransformNode[];
  47565. /**
  47566. * List of new skeletons
  47567. */
  47568. skeletons: Skeleton[];
  47569. /**
  47570. * List of new animation groups
  47571. */
  47572. animationGroups: AnimationGroup[];
  47573. }
  47574. /**
  47575. * Container with a set of assets that can be added or removed from a scene.
  47576. */
  47577. export class AssetContainer extends AbstractScene {
  47578. private _wasAddedToScene;
  47579. /**
  47580. * The scene the AssetContainer belongs to.
  47581. */
  47582. scene: Scene;
  47583. /**
  47584. * Instantiates an AssetContainer.
  47585. * @param scene The scene the AssetContainer belongs to.
  47586. */
  47587. constructor(scene: Scene);
  47588. /**
  47589. * Instantiate or clone all meshes and add the new ones to the scene.
  47590. * Skeletons and animation groups will all be cloned
  47591. * @param nameFunction defines an optional function used to get new names for clones
  47592. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  47593. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  47594. */
  47595. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  47596. /**
  47597. * Adds all the assets from the container to the scene.
  47598. */
  47599. addAllToScene(): void;
  47600. /**
  47601. * Removes all the assets in the container from the scene
  47602. */
  47603. removeAllFromScene(): void;
  47604. /**
  47605. * Disposes all the assets in the container
  47606. */
  47607. dispose(): void;
  47608. private _moveAssets;
  47609. /**
  47610. * Removes all the assets contained in the scene and adds them to the container.
  47611. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  47612. */
  47613. moveAllFromScene(keepAssets?: KeepAssets): void;
  47614. /**
  47615. * 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.
  47616. * @returns the root mesh
  47617. */
  47618. createRootMesh(): Mesh;
  47619. /**
  47620. * Merge animations (direct and animation groups) from this asset container into a scene
  47621. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47622. * @param animatables set of animatables to retarget to a node from the scene
  47623. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  47624. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  47625. */
  47626. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  47627. }
  47628. }
  47629. declare module BABYLON {
  47630. /**
  47631. * Defines how the parser contract is defined.
  47632. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  47633. */
  47634. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  47635. /**
  47636. * Defines how the individual parser contract is defined.
  47637. * These parser can parse an individual asset
  47638. */
  47639. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  47640. /**
  47641. * Base class of the scene acting as a container for the different elements composing a scene.
  47642. * This class is dynamically extended by the different components of the scene increasing
  47643. * flexibility and reducing coupling
  47644. */
  47645. export abstract class AbstractScene {
  47646. /**
  47647. * Stores the list of available parsers in the application.
  47648. */
  47649. private static _BabylonFileParsers;
  47650. /**
  47651. * Stores the list of available individual parsers in the application.
  47652. */
  47653. private static _IndividualBabylonFileParsers;
  47654. /**
  47655. * Adds a parser in the list of available ones
  47656. * @param name Defines the name of the parser
  47657. * @param parser Defines the parser to add
  47658. */
  47659. static AddParser(name: string, parser: BabylonFileParser): void;
  47660. /**
  47661. * Gets a general parser from the list of avaialble ones
  47662. * @param name Defines the name of the parser
  47663. * @returns the requested parser or null
  47664. */
  47665. static GetParser(name: string): Nullable<BabylonFileParser>;
  47666. /**
  47667. * Adds n individual parser in the list of available ones
  47668. * @param name Defines the name of the parser
  47669. * @param parser Defines the parser to add
  47670. */
  47671. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47672. /**
  47673. * Gets an individual parser from the list of avaialble ones
  47674. * @param name Defines the name of the parser
  47675. * @returns the requested parser or null
  47676. */
  47677. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  47678. /**
  47679. * Parser json data and populate both a scene and its associated container object
  47680. * @param jsonData Defines the data to parse
  47681. * @param scene Defines the scene to parse the data for
  47682. * @param container Defines the container attached to the parsing sequence
  47683. * @param rootUrl Defines the root url of the data
  47684. */
  47685. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  47686. /**
  47687. * Gets the list of root nodes (ie. nodes with no parent)
  47688. */
  47689. rootNodes: Node[];
  47690. /** All of the cameras added to this scene
  47691. * @see https://doc.babylonjs.com/babylon101/cameras
  47692. */
  47693. cameras: Camera[];
  47694. /**
  47695. * All of the lights added to this scene
  47696. * @see https://doc.babylonjs.com/babylon101/lights
  47697. */
  47698. lights: Light[];
  47699. /**
  47700. * All of the (abstract) meshes added to this scene
  47701. */
  47702. meshes: AbstractMesh[];
  47703. /**
  47704. * The list of skeletons added to the scene
  47705. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  47706. */
  47707. skeletons: Skeleton[];
  47708. /**
  47709. * All of the particle systems added to this scene
  47710. * @see https://doc.babylonjs.com/babylon101/particles
  47711. */
  47712. particleSystems: IParticleSystem[];
  47713. /**
  47714. * Gets a list of Animations associated with the scene
  47715. */
  47716. animations: Animation[];
  47717. /**
  47718. * All of the animation groups added to this scene
  47719. * @see https://doc.babylonjs.com/how_to/group
  47720. */
  47721. animationGroups: AnimationGroup[];
  47722. /**
  47723. * All of the multi-materials added to this scene
  47724. * @see https://doc.babylonjs.com/how_to/multi_materials
  47725. */
  47726. multiMaterials: MultiMaterial[];
  47727. /**
  47728. * All of the materials added to this scene
  47729. * In the context of a Scene, it is not supposed to be modified manually.
  47730. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  47731. * Note also that the order of the Material within the array is not significant and might change.
  47732. * @see https://doc.babylonjs.com/babylon101/materials
  47733. */
  47734. materials: Material[];
  47735. /**
  47736. * The list of morph target managers added to the scene
  47737. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  47738. */
  47739. morphTargetManagers: MorphTargetManager[];
  47740. /**
  47741. * The list of geometries used in the scene.
  47742. */
  47743. geometries: Geometry[];
  47744. /**
  47745. * All of the tranform nodes added to this scene
  47746. * In the context of a Scene, it is not supposed to be modified manually.
  47747. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  47748. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  47749. * @see https://doc.babylonjs.com/how_to/transformnode
  47750. */
  47751. transformNodes: TransformNode[];
  47752. /**
  47753. * ActionManagers available on the scene.
  47754. */
  47755. actionManagers: AbstractActionManager[];
  47756. /**
  47757. * Textures to keep.
  47758. */
  47759. textures: BaseTexture[];
  47760. /** @hidden */
  47761. protected _environmentTexture: Nullable<BaseTexture>;
  47762. /**
  47763. * Texture used in all pbr material as the reflection texture.
  47764. * As in the majority of the scene they are the same (exception for multi room and so on),
  47765. * this is easier to reference from here than from all the materials.
  47766. */
  47767. get environmentTexture(): Nullable<BaseTexture>;
  47768. set environmentTexture(value: Nullable<BaseTexture>);
  47769. /**
  47770. * The list of postprocesses added to the scene
  47771. */
  47772. postProcesses: PostProcess[];
  47773. /**
  47774. * @returns all meshes, lights, cameras, transformNodes and bones
  47775. */
  47776. getNodes(): Array<Node>;
  47777. }
  47778. }
  47779. declare module BABYLON {
  47780. /**
  47781. * Interface used to define options for Sound class
  47782. */
  47783. export interface ISoundOptions {
  47784. /**
  47785. * Does the sound autoplay once loaded.
  47786. */
  47787. autoplay?: boolean;
  47788. /**
  47789. * Does the sound loop after it finishes playing once.
  47790. */
  47791. loop?: boolean;
  47792. /**
  47793. * Sound's volume
  47794. */
  47795. volume?: number;
  47796. /**
  47797. * Is it a spatial sound?
  47798. */
  47799. spatialSound?: boolean;
  47800. /**
  47801. * Maximum distance to hear that sound
  47802. */
  47803. maxDistance?: number;
  47804. /**
  47805. * Uses user defined attenuation function
  47806. */
  47807. useCustomAttenuation?: boolean;
  47808. /**
  47809. * Define the roll off factor of spatial sounds.
  47810. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47811. */
  47812. rolloffFactor?: number;
  47813. /**
  47814. * Define the reference distance the sound should be heard perfectly.
  47815. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47816. */
  47817. refDistance?: number;
  47818. /**
  47819. * Define the distance attenuation model the sound will follow.
  47820. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47821. */
  47822. distanceModel?: string;
  47823. /**
  47824. * Defines the playback speed (1 by default)
  47825. */
  47826. playbackRate?: number;
  47827. /**
  47828. * Defines if the sound is from a streaming source
  47829. */
  47830. streaming?: boolean;
  47831. /**
  47832. * Defines an optional length (in seconds) inside the sound file
  47833. */
  47834. length?: number;
  47835. /**
  47836. * Defines an optional offset (in seconds) inside the sound file
  47837. */
  47838. offset?: number;
  47839. /**
  47840. * If true, URLs will not be required to state the audio file codec to use.
  47841. */
  47842. skipCodecCheck?: boolean;
  47843. }
  47844. }
  47845. declare module BABYLON {
  47846. /**
  47847. * Defines a sound that can be played in the application.
  47848. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  47849. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47850. */
  47851. export class Sound {
  47852. /**
  47853. * The name of the sound in the scene.
  47854. */
  47855. name: string;
  47856. /**
  47857. * Does the sound autoplay once loaded.
  47858. */
  47859. autoplay: boolean;
  47860. private _loop;
  47861. /**
  47862. * Does the sound loop after it finishes playing once.
  47863. */
  47864. get loop(): boolean;
  47865. set loop(value: boolean);
  47866. /**
  47867. * Does the sound use a custom attenuation curve to simulate the falloff
  47868. * happening when the source gets further away from the camera.
  47869. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  47870. */
  47871. useCustomAttenuation: boolean;
  47872. /**
  47873. * The sound track id this sound belongs to.
  47874. */
  47875. soundTrackId: number;
  47876. /**
  47877. * Is this sound currently played.
  47878. */
  47879. isPlaying: boolean;
  47880. /**
  47881. * Is this sound currently paused.
  47882. */
  47883. isPaused: boolean;
  47884. /**
  47885. * Does this sound enables spatial sound.
  47886. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47887. */
  47888. spatialSound: boolean;
  47889. /**
  47890. * Define the reference distance the sound should be heard perfectly.
  47891. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47892. */
  47893. refDistance: number;
  47894. /**
  47895. * Define the roll off factor of spatial sounds.
  47896. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47897. */
  47898. rolloffFactor: number;
  47899. /**
  47900. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  47901. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47902. */
  47903. maxDistance: number;
  47904. /**
  47905. * Define the distance attenuation model the sound will follow.
  47906. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47907. */
  47908. distanceModel: string;
  47909. /**
  47910. * @hidden
  47911. * Back Compat
  47912. **/
  47913. onended: () => any;
  47914. /**
  47915. * Gets or sets an object used to store user defined information for the sound.
  47916. */
  47917. metadata: any;
  47918. /**
  47919. * Observable event when the current playing sound finishes.
  47920. */
  47921. onEndedObservable: Observable<Sound>;
  47922. /**
  47923. * Gets the current time for the sound.
  47924. */
  47925. get currentTime(): number;
  47926. private _panningModel;
  47927. private _playbackRate;
  47928. private _streaming;
  47929. private _startTime;
  47930. private _startOffset;
  47931. private _position;
  47932. /** @hidden */
  47933. _positionInEmitterSpace: boolean;
  47934. private _localDirection;
  47935. private _volume;
  47936. private _isReadyToPlay;
  47937. private _isDirectional;
  47938. private _readyToPlayCallback;
  47939. private _audioBuffer;
  47940. private _soundSource;
  47941. private _streamingSource;
  47942. private _soundPanner;
  47943. private _soundGain;
  47944. private _inputAudioNode;
  47945. private _outputAudioNode;
  47946. private _coneInnerAngle;
  47947. private _coneOuterAngle;
  47948. private _coneOuterGain;
  47949. private _scene;
  47950. private _connectedTransformNode;
  47951. private _customAttenuationFunction;
  47952. private _registerFunc;
  47953. private _isOutputConnected;
  47954. private _htmlAudioElement;
  47955. private _urlType;
  47956. private _length?;
  47957. private _offset?;
  47958. /** @hidden */
  47959. static _SceneComponentInitialization: (scene: Scene) => void;
  47960. /**
  47961. * Create a sound and attach it to a scene
  47962. * @param name Name of your sound
  47963. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  47964. * @param scene defines the scene the sound belongs to
  47965. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  47966. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  47967. */
  47968. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  47969. /**
  47970. * Release the sound and its associated resources
  47971. */
  47972. dispose(): void;
  47973. /**
  47974. * Gets if the sounds is ready to be played or not.
  47975. * @returns true if ready, otherwise false
  47976. */
  47977. isReady(): boolean;
  47978. /**
  47979. * Get the current class name.
  47980. * @returns current class name
  47981. */
  47982. getClassName(): string;
  47983. private _soundLoaded;
  47984. /**
  47985. * Sets the data of the sound from an audiobuffer
  47986. * @param audioBuffer The audioBuffer containing the data
  47987. */
  47988. setAudioBuffer(audioBuffer: AudioBuffer): void;
  47989. /**
  47990. * Updates the current sounds options such as maxdistance, loop...
  47991. * @param options A JSON object containing values named as the object properties
  47992. */
  47993. updateOptions(options: ISoundOptions): void;
  47994. private _createSpatialParameters;
  47995. private _updateSpatialParameters;
  47996. /**
  47997. * Switch the panning model to HRTF:
  47998. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  47999. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48000. */
  48001. switchPanningModelToHRTF(): void;
  48002. /**
  48003. * Switch the panning model to Equal Power:
  48004. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48005. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48006. */
  48007. switchPanningModelToEqualPower(): void;
  48008. private _switchPanningModel;
  48009. /**
  48010. * Connect this sound to a sound track audio node like gain...
  48011. * @param soundTrackAudioNode the sound track audio node to connect to
  48012. */
  48013. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  48014. /**
  48015. * Transform this sound into a directional source
  48016. * @param coneInnerAngle Size of the inner cone in degree
  48017. * @param coneOuterAngle Size of the outer cone in degree
  48018. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  48019. */
  48020. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  48021. /**
  48022. * Gets or sets the inner angle for the directional cone.
  48023. */
  48024. get directionalConeInnerAngle(): number;
  48025. /**
  48026. * Gets or sets the inner angle for the directional cone.
  48027. */
  48028. set directionalConeInnerAngle(value: number);
  48029. /**
  48030. * Gets or sets the outer angle for the directional cone.
  48031. */
  48032. get directionalConeOuterAngle(): number;
  48033. /**
  48034. * Gets or sets the outer angle for the directional cone.
  48035. */
  48036. set directionalConeOuterAngle(value: number);
  48037. /**
  48038. * Sets the position of the emitter if spatial sound is enabled
  48039. * @param newPosition Defines the new posisiton
  48040. */
  48041. setPosition(newPosition: Vector3): void;
  48042. /**
  48043. * Sets the local direction of the emitter if spatial sound is enabled
  48044. * @param newLocalDirection Defines the new local direction
  48045. */
  48046. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48047. private _updateDirection;
  48048. /** @hidden */
  48049. updateDistanceFromListener(): void;
  48050. /**
  48051. * Sets a new custom attenuation function for the sound.
  48052. * @param callback Defines the function used for the attenuation
  48053. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48054. */
  48055. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48056. /**
  48057. * Play the sound
  48058. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48059. * @param offset (optional) Start the sound at a specific time in seconds
  48060. * @param length (optional) Sound duration (in seconds)
  48061. */
  48062. play(time?: number, offset?: number, length?: number): void;
  48063. private _onended;
  48064. /**
  48065. * Stop the sound
  48066. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48067. */
  48068. stop(time?: number): void;
  48069. /**
  48070. * Put the sound in pause
  48071. */
  48072. pause(): void;
  48073. /**
  48074. * Sets a dedicated volume for this sounds
  48075. * @param newVolume Define the new volume of the sound
  48076. * @param time Define time for gradual change to new volume
  48077. */
  48078. setVolume(newVolume: number, time?: number): void;
  48079. /**
  48080. * Set the sound play back rate
  48081. * @param newPlaybackRate Define the playback rate the sound should be played at
  48082. */
  48083. setPlaybackRate(newPlaybackRate: number): void;
  48084. /**
  48085. * Gets the volume of the sound.
  48086. * @returns the volume of the sound
  48087. */
  48088. getVolume(): number;
  48089. /**
  48090. * Attach the sound to a dedicated mesh
  48091. * @param transformNode The transform node to connect the sound with
  48092. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48093. */
  48094. attachToMesh(transformNode: TransformNode): void;
  48095. /**
  48096. * Detach the sound from the previously attached mesh
  48097. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48098. */
  48099. detachFromMesh(): void;
  48100. private _onRegisterAfterWorldMatrixUpdate;
  48101. /**
  48102. * Clone the current sound in the scene.
  48103. * @returns the new sound clone
  48104. */
  48105. clone(): Nullable<Sound>;
  48106. /**
  48107. * Gets the current underlying audio buffer containing the data
  48108. * @returns the audio buffer
  48109. */
  48110. getAudioBuffer(): Nullable<AudioBuffer>;
  48111. /**
  48112. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48113. * @returns the source node
  48114. */
  48115. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48116. /**
  48117. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48118. * @returns the gain node
  48119. */
  48120. getSoundGain(): Nullable<GainNode>;
  48121. /**
  48122. * Serializes the Sound in a JSON representation
  48123. * @returns the JSON representation of the sound
  48124. */
  48125. serialize(): any;
  48126. /**
  48127. * Parse a JSON representation of a sound to innstantiate in a given scene
  48128. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48129. * @param scene Define the scene the new parsed sound should be created in
  48130. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48131. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  48132. * @returns the newly parsed sound
  48133. */
  48134. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48135. }
  48136. }
  48137. declare module BABYLON {
  48138. /**
  48139. * This defines an action helpful to play a defined sound on a triggered action.
  48140. */
  48141. export class PlaySoundAction extends Action {
  48142. private _sound;
  48143. /**
  48144. * Instantiate the action
  48145. * @param triggerOptions defines the trigger options
  48146. * @param sound defines the sound to play
  48147. * @param condition defines the trigger related conditions
  48148. */
  48149. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48150. /** @hidden */
  48151. _prepare(): void;
  48152. /**
  48153. * Execute the action and play the sound.
  48154. */
  48155. execute(): void;
  48156. /**
  48157. * Serializes the actions and its related information.
  48158. * @param parent defines the object to serialize in
  48159. * @returns the serialized object
  48160. */
  48161. serialize(parent: any): any;
  48162. }
  48163. /**
  48164. * This defines an action helpful to stop a defined sound on a triggered action.
  48165. */
  48166. export class StopSoundAction extends Action {
  48167. private _sound;
  48168. /**
  48169. * Instantiate the action
  48170. * @param triggerOptions defines the trigger options
  48171. * @param sound defines the sound to stop
  48172. * @param condition defines the trigger related conditions
  48173. */
  48174. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48175. /** @hidden */
  48176. _prepare(): void;
  48177. /**
  48178. * Execute the action and stop the sound.
  48179. */
  48180. execute(): void;
  48181. /**
  48182. * Serializes the actions and its related information.
  48183. * @param parent defines the object to serialize in
  48184. * @returns the serialized object
  48185. */
  48186. serialize(parent: any): any;
  48187. }
  48188. }
  48189. declare module BABYLON {
  48190. /**
  48191. * This defines an action responsible to change the value of a property
  48192. * by interpolating between its current value and the newly set one once triggered.
  48193. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48194. */
  48195. export class InterpolateValueAction extends Action {
  48196. /**
  48197. * Defines the path of the property where the value should be interpolated
  48198. */
  48199. propertyPath: string;
  48200. /**
  48201. * Defines the target value at the end of the interpolation.
  48202. */
  48203. value: any;
  48204. /**
  48205. * Defines the time it will take for the property to interpolate to the value.
  48206. */
  48207. duration: number;
  48208. /**
  48209. * Defines if the other scene animations should be stopped when the action has been triggered
  48210. */
  48211. stopOtherAnimations?: boolean;
  48212. /**
  48213. * Defines a callback raised once the interpolation animation has been done.
  48214. */
  48215. onInterpolationDone?: () => void;
  48216. /**
  48217. * Observable triggered once the interpolation animation has been done.
  48218. */
  48219. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48220. private _target;
  48221. private _effectiveTarget;
  48222. private _property;
  48223. /**
  48224. * Instantiate the action
  48225. * @param triggerOptions defines the trigger options
  48226. * @param target defines the object containing the value to interpolate
  48227. * @param propertyPath defines the path to the property in the target object
  48228. * @param value defines the target value at the end of the interpolation
  48229. * @param duration deines the time it will take for the property to interpolate to the value.
  48230. * @param condition defines the trigger related conditions
  48231. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48232. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48233. */
  48234. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48235. /** @hidden */
  48236. _prepare(): void;
  48237. /**
  48238. * Execute the action starts the value interpolation.
  48239. */
  48240. execute(): void;
  48241. /**
  48242. * Serializes the actions and its related information.
  48243. * @param parent defines the object to serialize in
  48244. * @returns the serialized object
  48245. */
  48246. serialize(parent: any): any;
  48247. }
  48248. }
  48249. declare module BABYLON {
  48250. /**
  48251. * This represents the default audio engine used in babylon.
  48252. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48253. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48254. */
  48255. export class AudioEngine implements IAudioEngine {
  48256. private _audioContext;
  48257. private _audioContextInitialized;
  48258. private _muteButton;
  48259. private _hostElement;
  48260. /**
  48261. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48262. */
  48263. canUseWebAudio: boolean;
  48264. /**
  48265. * The master gain node defines the global audio volume of your audio engine.
  48266. */
  48267. masterGain: GainNode;
  48268. /**
  48269. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48270. * @ignoreNaming
  48271. */
  48272. WarnedWebAudioUnsupported: boolean;
  48273. /**
  48274. * Gets whether or not mp3 are supported by your browser.
  48275. */
  48276. isMP3supported: boolean;
  48277. /**
  48278. * Gets whether or not ogg are supported by your browser.
  48279. */
  48280. isOGGsupported: boolean;
  48281. /**
  48282. * Gets whether audio has been unlocked on the device.
  48283. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48284. * a user interaction has happened.
  48285. */
  48286. unlocked: boolean;
  48287. /**
  48288. * Defines if the audio engine relies on a custom unlocked button.
  48289. * In this case, the embedded button will not be displayed.
  48290. */
  48291. useCustomUnlockedButton: boolean;
  48292. /**
  48293. * Event raised when audio has been unlocked on the browser.
  48294. */
  48295. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48296. /**
  48297. * Event raised when audio has been locked on the browser.
  48298. */
  48299. onAudioLockedObservable: Observable<IAudioEngine>;
  48300. /**
  48301. * Gets the current AudioContext if available.
  48302. */
  48303. get audioContext(): Nullable<AudioContext>;
  48304. private _connectedAnalyser;
  48305. /**
  48306. * Instantiates a new audio engine.
  48307. *
  48308. * There should be only one per page as some browsers restrict the number
  48309. * of audio contexts you can create.
  48310. * @param hostElement defines the host element where to display the mute icon if necessary
  48311. */
  48312. constructor(hostElement?: Nullable<HTMLElement>);
  48313. /**
  48314. * Flags the audio engine in Locked state.
  48315. * This happens due to new browser policies preventing audio to autoplay.
  48316. */
  48317. lock(): void;
  48318. /**
  48319. * Unlocks the audio engine once a user action has been done on the dom.
  48320. * This is helpful to resume play once browser policies have been satisfied.
  48321. */
  48322. unlock(): void;
  48323. private _resumeAudioContext;
  48324. private _initializeAudioContext;
  48325. private _tryToRun;
  48326. private _triggerRunningState;
  48327. private _triggerSuspendedState;
  48328. private _displayMuteButton;
  48329. private _moveButtonToTopLeft;
  48330. private _onResize;
  48331. private _hideMuteButton;
  48332. /**
  48333. * Destroy and release the resources associated with the audio ccontext.
  48334. */
  48335. dispose(): void;
  48336. /**
  48337. * Gets the global volume sets on the master gain.
  48338. * @returns the global volume if set or -1 otherwise
  48339. */
  48340. getGlobalVolume(): number;
  48341. /**
  48342. * Sets the global volume of your experience (sets on the master gain).
  48343. * @param newVolume Defines the new global volume of the application
  48344. */
  48345. setGlobalVolume(newVolume: number): void;
  48346. /**
  48347. * Connect the audio engine to an audio analyser allowing some amazing
  48348. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48349. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48350. * @param analyser The analyser to connect to the engine
  48351. */
  48352. connectToAnalyser(analyser: Analyser): void;
  48353. }
  48354. }
  48355. declare module BABYLON {
  48356. /**
  48357. * Options allowed during the creation of a sound track.
  48358. */
  48359. export interface ISoundTrackOptions {
  48360. /**
  48361. * The volume the sound track should take during creation
  48362. */
  48363. volume?: number;
  48364. /**
  48365. * Define if the sound track is the main sound track of the scene
  48366. */
  48367. mainTrack?: boolean;
  48368. }
  48369. /**
  48370. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  48371. * It will be also used in a future release to apply effects on a specific track.
  48372. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48373. */
  48374. export class SoundTrack {
  48375. /**
  48376. * The unique identifier of the sound track in the scene.
  48377. */
  48378. id: number;
  48379. /**
  48380. * The list of sounds included in the sound track.
  48381. */
  48382. soundCollection: Array<Sound>;
  48383. private _outputAudioNode;
  48384. private _scene;
  48385. private _connectedAnalyser;
  48386. private _options;
  48387. private _isInitialized;
  48388. /**
  48389. * Creates a new sound track.
  48390. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48391. * @param scene Define the scene the sound track belongs to
  48392. * @param options
  48393. */
  48394. constructor(scene: Scene, options?: ISoundTrackOptions);
  48395. private _initializeSoundTrackAudioGraph;
  48396. /**
  48397. * Release the sound track and its associated resources
  48398. */
  48399. dispose(): void;
  48400. /**
  48401. * Adds a sound to this sound track
  48402. * @param sound define the cound to add
  48403. * @ignoreNaming
  48404. */
  48405. addSound(sound: Sound): void;
  48406. /**
  48407. * Removes a sound to this sound track
  48408. * @param sound define the cound to remove
  48409. * @ignoreNaming
  48410. */
  48411. removeSound(sound: Sound): void;
  48412. /**
  48413. * Set a global volume for the full sound track.
  48414. * @param newVolume Define the new volume of the sound track
  48415. */
  48416. setVolume(newVolume: number): void;
  48417. /**
  48418. * Switch the panning model to HRTF:
  48419. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48420. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48421. */
  48422. switchPanningModelToHRTF(): void;
  48423. /**
  48424. * Switch the panning model to Equal Power:
  48425. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48426. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48427. */
  48428. switchPanningModelToEqualPower(): void;
  48429. /**
  48430. * Connect the sound track to an audio analyser allowing some amazing
  48431. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48432. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48433. * @param analyser The analyser to connect to the engine
  48434. */
  48435. connectToAnalyser(analyser: Analyser): void;
  48436. }
  48437. }
  48438. declare module BABYLON {
  48439. interface AbstractScene {
  48440. /**
  48441. * The list of sounds used in the scene.
  48442. */
  48443. sounds: Nullable<Array<Sound>>;
  48444. }
  48445. interface Scene {
  48446. /**
  48447. * @hidden
  48448. * Backing field
  48449. */
  48450. _mainSoundTrack: SoundTrack;
  48451. /**
  48452. * The main sound track played by the scene.
  48453. * It cotains your primary collection of sounds.
  48454. */
  48455. mainSoundTrack: SoundTrack;
  48456. /**
  48457. * The list of sound tracks added to the scene
  48458. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48459. */
  48460. soundTracks: Nullable<Array<SoundTrack>>;
  48461. /**
  48462. * Gets a sound using a given name
  48463. * @param name defines the name to search for
  48464. * @return the found sound or null if not found at all.
  48465. */
  48466. getSoundByName(name: string): Nullable<Sound>;
  48467. /**
  48468. * Gets or sets if audio support is enabled
  48469. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48470. */
  48471. audioEnabled: boolean;
  48472. /**
  48473. * Gets or sets if audio will be output to headphones
  48474. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48475. */
  48476. headphone: boolean;
  48477. /**
  48478. * Gets or sets custom audio listener position provider
  48479. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48480. */
  48481. audioListenerPositionProvider: Nullable<() => Vector3>;
  48482. /**
  48483. * Gets or sets a refresh rate when using 3D audio positioning
  48484. */
  48485. audioPositioningRefreshRate: number;
  48486. }
  48487. /**
  48488. * Defines the sound scene component responsible to manage any sounds
  48489. * in a given scene.
  48490. */
  48491. export class AudioSceneComponent implements ISceneSerializableComponent {
  48492. private static _CameraDirectionLH;
  48493. private static _CameraDirectionRH;
  48494. /**
  48495. * The component name helpfull to identify the component in the list of scene components.
  48496. */
  48497. readonly name: string;
  48498. /**
  48499. * The scene the component belongs to.
  48500. */
  48501. scene: Scene;
  48502. private _audioEnabled;
  48503. /**
  48504. * Gets whether audio is enabled or not.
  48505. * Please use related enable/disable method to switch state.
  48506. */
  48507. get audioEnabled(): boolean;
  48508. private _headphone;
  48509. /**
  48510. * Gets whether audio is outputing to headphone or not.
  48511. * Please use the according Switch methods to change output.
  48512. */
  48513. get headphone(): boolean;
  48514. /**
  48515. * Gets or sets a refresh rate when using 3D audio positioning
  48516. */
  48517. audioPositioningRefreshRate: number;
  48518. private _audioListenerPositionProvider;
  48519. /**
  48520. * Gets the current audio listener position provider
  48521. */
  48522. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  48523. /**
  48524. * Sets a custom listener position for all sounds in the scene
  48525. * By default, this is the position of the first active camera
  48526. */
  48527. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  48528. /**
  48529. * Creates a new instance of the component for the given scene
  48530. * @param scene Defines the scene to register the component in
  48531. */
  48532. constructor(scene: Scene);
  48533. /**
  48534. * Registers the component in a given scene
  48535. */
  48536. register(): void;
  48537. /**
  48538. * Rebuilds the elements related to this component in case of
  48539. * context lost for instance.
  48540. */
  48541. rebuild(): void;
  48542. /**
  48543. * Serializes the component data to the specified json object
  48544. * @param serializationObject The object to serialize to
  48545. */
  48546. serialize(serializationObject: any): void;
  48547. /**
  48548. * Adds all the elements from the container to the scene
  48549. * @param container the container holding the elements
  48550. */
  48551. addFromContainer(container: AbstractScene): void;
  48552. /**
  48553. * Removes all the elements in the container from the scene
  48554. * @param container contains the elements to remove
  48555. * @param dispose if the removed element should be disposed (default: false)
  48556. */
  48557. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48558. /**
  48559. * Disposes the component and the associated ressources.
  48560. */
  48561. dispose(): void;
  48562. /**
  48563. * Disables audio in the associated scene.
  48564. */
  48565. disableAudio(): void;
  48566. /**
  48567. * Enables audio in the associated scene.
  48568. */
  48569. enableAudio(): void;
  48570. /**
  48571. * Switch audio to headphone output.
  48572. */
  48573. switchAudioModeForHeadphones(): void;
  48574. /**
  48575. * Switch audio to normal speakers.
  48576. */
  48577. switchAudioModeForNormalSpeakers(): void;
  48578. private _cachedCameraDirection;
  48579. private _cachedCameraPosition;
  48580. private _lastCheck;
  48581. private _afterRender;
  48582. }
  48583. }
  48584. declare module BABYLON {
  48585. /**
  48586. * Wraps one or more Sound objects and selects one with random weight for playback.
  48587. */
  48588. export class WeightedSound {
  48589. /** When true a Sound will be selected and played when the current playing Sound completes. */
  48590. loop: boolean;
  48591. private _coneInnerAngle;
  48592. private _coneOuterAngle;
  48593. private _volume;
  48594. /** A Sound is currently playing. */
  48595. isPlaying: boolean;
  48596. /** A Sound is currently paused. */
  48597. isPaused: boolean;
  48598. private _sounds;
  48599. private _weights;
  48600. private _currentIndex?;
  48601. /**
  48602. * Creates a new WeightedSound from the list of sounds given.
  48603. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  48604. * @param sounds Array of Sounds that will be selected from.
  48605. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  48606. */
  48607. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  48608. /**
  48609. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  48610. */
  48611. get directionalConeInnerAngle(): number;
  48612. /**
  48613. * The size of cone in degress for a directional sound in which there will be no attenuation.
  48614. */
  48615. set directionalConeInnerAngle(value: number);
  48616. /**
  48617. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48618. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48619. */
  48620. get directionalConeOuterAngle(): number;
  48621. /**
  48622. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48623. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48624. */
  48625. set directionalConeOuterAngle(value: number);
  48626. /**
  48627. * Playback volume.
  48628. */
  48629. get volume(): number;
  48630. /**
  48631. * Playback volume.
  48632. */
  48633. set volume(value: number);
  48634. private _onended;
  48635. /**
  48636. * Suspend playback
  48637. */
  48638. pause(): void;
  48639. /**
  48640. * Stop playback
  48641. */
  48642. stop(): void;
  48643. /**
  48644. * Start playback.
  48645. * @param startOffset Position the clip head at a specific time in seconds.
  48646. */
  48647. play(startOffset?: number): void;
  48648. }
  48649. }
  48650. declare module BABYLON {
  48651. /**
  48652. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  48653. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48654. */
  48655. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  48656. /**
  48657. * Gets the name of the behavior.
  48658. */
  48659. get name(): string;
  48660. /**
  48661. * The easing function used by animations
  48662. */
  48663. static EasingFunction: BackEase;
  48664. /**
  48665. * The easing mode used by animations
  48666. */
  48667. static EasingMode: number;
  48668. /**
  48669. * The duration of the animation, in milliseconds
  48670. */
  48671. transitionDuration: number;
  48672. /**
  48673. * Length of the distance animated by the transition when lower radius is reached
  48674. */
  48675. lowerRadiusTransitionRange: number;
  48676. /**
  48677. * Length of the distance animated by the transition when upper radius is reached
  48678. */
  48679. upperRadiusTransitionRange: number;
  48680. private _autoTransitionRange;
  48681. /**
  48682. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48683. */
  48684. get autoTransitionRange(): boolean;
  48685. /**
  48686. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48687. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  48688. */
  48689. set autoTransitionRange(value: boolean);
  48690. private _attachedCamera;
  48691. private _onAfterCheckInputsObserver;
  48692. private _onMeshTargetChangedObserver;
  48693. /**
  48694. * Initializes the behavior.
  48695. */
  48696. init(): void;
  48697. /**
  48698. * Attaches the behavior to its arc rotate camera.
  48699. * @param camera Defines the camera to attach the behavior to
  48700. */
  48701. attach(camera: ArcRotateCamera): void;
  48702. /**
  48703. * Detaches the behavior from its current arc rotate camera.
  48704. */
  48705. detach(): void;
  48706. private _radiusIsAnimating;
  48707. private _radiusBounceTransition;
  48708. private _animatables;
  48709. private _cachedWheelPrecision;
  48710. /**
  48711. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  48712. * @param radiusLimit The limit to check against.
  48713. * @return Bool to indicate if at limit.
  48714. */
  48715. private _isRadiusAtLimit;
  48716. /**
  48717. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  48718. * @param radiusDelta The delta by which to animate to. Can be negative.
  48719. */
  48720. private _applyBoundRadiusAnimation;
  48721. /**
  48722. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  48723. */
  48724. protected _clearAnimationLocks(): void;
  48725. /**
  48726. * Stops and removes all animations that have been applied to the camera
  48727. */
  48728. stopAllAnimations(): void;
  48729. }
  48730. }
  48731. declare module BABYLON {
  48732. /**
  48733. * 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.
  48734. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48735. */
  48736. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  48737. /**
  48738. * Gets the name of the behavior.
  48739. */
  48740. get name(): string;
  48741. private _mode;
  48742. private _radiusScale;
  48743. private _positionScale;
  48744. private _defaultElevation;
  48745. private _elevationReturnTime;
  48746. private _elevationReturnWaitTime;
  48747. private _zoomStopsAnimation;
  48748. private _framingTime;
  48749. /**
  48750. * The easing function used by animations
  48751. */
  48752. static EasingFunction: ExponentialEase;
  48753. /**
  48754. * The easing mode used by animations
  48755. */
  48756. static EasingMode: number;
  48757. /**
  48758. * Sets the current mode used by the behavior
  48759. */
  48760. set mode(mode: number);
  48761. /**
  48762. * Gets current mode used by the behavior.
  48763. */
  48764. get mode(): number;
  48765. /**
  48766. * Sets the scale applied to the radius (1 by default)
  48767. */
  48768. set radiusScale(radius: number);
  48769. /**
  48770. * Gets the scale applied to the radius
  48771. */
  48772. get radiusScale(): number;
  48773. /**
  48774. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48775. */
  48776. set positionScale(scale: number);
  48777. /**
  48778. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48779. */
  48780. get positionScale(): number;
  48781. /**
  48782. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48783. * behaviour is triggered, in radians.
  48784. */
  48785. set defaultElevation(elevation: number);
  48786. /**
  48787. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48788. * behaviour is triggered, in radians.
  48789. */
  48790. get defaultElevation(): number;
  48791. /**
  48792. * Sets the time (in milliseconds) taken to return to the default beta position.
  48793. * Negative value indicates camera should not return to default.
  48794. */
  48795. set elevationReturnTime(speed: number);
  48796. /**
  48797. * Gets the time (in milliseconds) taken to return to the default beta position.
  48798. * Negative value indicates camera should not return to default.
  48799. */
  48800. get elevationReturnTime(): number;
  48801. /**
  48802. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48803. */
  48804. set elevationReturnWaitTime(time: number);
  48805. /**
  48806. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48807. */
  48808. get elevationReturnWaitTime(): number;
  48809. /**
  48810. * Sets the flag that indicates if user zooming should stop animation.
  48811. */
  48812. set zoomStopsAnimation(flag: boolean);
  48813. /**
  48814. * Gets the flag that indicates if user zooming should stop animation.
  48815. */
  48816. get zoomStopsAnimation(): boolean;
  48817. /**
  48818. * Sets the transition time when framing the mesh, in milliseconds
  48819. */
  48820. set framingTime(time: number);
  48821. /**
  48822. * Gets the transition time when framing the mesh, in milliseconds
  48823. */
  48824. get framingTime(): number;
  48825. /**
  48826. * Define if the behavior should automatically change the configured
  48827. * camera limits and sensibilities.
  48828. */
  48829. autoCorrectCameraLimitsAndSensibility: boolean;
  48830. private _onPrePointerObservableObserver;
  48831. private _onAfterCheckInputsObserver;
  48832. private _onMeshTargetChangedObserver;
  48833. private _attachedCamera;
  48834. private _isPointerDown;
  48835. private _lastInteractionTime;
  48836. /**
  48837. * Initializes the behavior.
  48838. */
  48839. init(): void;
  48840. /**
  48841. * Attaches the behavior to its arc rotate camera.
  48842. * @param camera Defines the camera to attach the behavior to
  48843. */
  48844. attach(camera: ArcRotateCamera): void;
  48845. /**
  48846. * Detaches the behavior from its current arc rotate camera.
  48847. */
  48848. detach(): void;
  48849. private _animatables;
  48850. private _betaIsAnimating;
  48851. private _betaTransition;
  48852. private _radiusTransition;
  48853. private _vectorTransition;
  48854. /**
  48855. * Targets the given mesh and updates zoom level accordingly.
  48856. * @param mesh The mesh to target.
  48857. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48858. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48859. */
  48860. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48861. /**
  48862. * Targets the given mesh with its children and updates zoom level accordingly.
  48863. * @param mesh The mesh to target.
  48864. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48865. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48866. */
  48867. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48868. /**
  48869. * Targets the given meshes with their children and updates zoom level accordingly.
  48870. * @param meshes The mesh to target.
  48871. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48872. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48873. */
  48874. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48875. /**
  48876. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  48877. * @param minimumWorld Determines the smaller position of the bounding box extend
  48878. * @param maximumWorld Determines the bigger position of the bounding box extend
  48879. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48880. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48881. */
  48882. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48883. /**
  48884. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  48885. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  48886. * frustum width.
  48887. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  48888. * to fully enclose the mesh in the viewing frustum.
  48889. */
  48890. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  48891. /**
  48892. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  48893. * is automatically returned to its default position (expected to be above ground plane).
  48894. */
  48895. private _maintainCameraAboveGround;
  48896. /**
  48897. * Returns the frustum slope based on the canvas ratio and camera FOV
  48898. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  48899. */
  48900. private _getFrustumSlope;
  48901. /**
  48902. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  48903. */
  48904. private _clearAnimationLocks;
  48905. /**
  48906. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48907. */
  48908. private _applyUserInteraction;
  48909. /**
  48910. * Stops and removes all animations that have been applied to the camera
  48911. */
  48912. stopAllAnimations(): void;
  48913. /**
  48914. * Gets a value indicating if the user is moving the camera
  48915. */
  48916. get isUserIsMoving(): boolean;
  48917. /**
  48918. * The camera can move all the way towards the mesh.
  48919. */
  48920. static IgnoreBoundsSizeMode: number;
  48921. /**
  48922. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  48923. */
  48924. static FitFrustumSidesMode: number;
  48925. }
  48926. }
  48927. declare module BABYLON {
  48928. /**
  48929. * Base class for Camera Pointer Inputs.
  48930. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  48931. * for example usage.
  48932. */
  48933. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  48934. /**
  48935. * Defines the camera the input is attached to.
  48936. */
  48937. abstract camera: Camera;
  48938. /**
  48939. * Whether keyboard modifier keys are pressed at time of last mouse event.
  48940. */
  48941. protected _altKey: boolean;
  48942. protected _ctrlKey: boolean;
  48943. protected _metaKey: boolean;
  48944. protected _shiftKey: boolean;
  48945. /**
  48946. * Which mouse buttons were pressed at time of last mouse event.
  48947. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  48948. */
  48949. protected _buttonsPressed: number;
  48950. /**
  48951. * Defines the buttons associated with the input to handle camera move.
  48952. */
  48953. buttons: number[];
  48954. /**
  48955. * Attach the input controls to a specific dom element to get the input from.
  48956. * @param element Defines the element the controls should be listened from
  48957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48958. */
  48959. attachControl(noPreventDefault?: boolean): void;
  48960. /**
  48961. * Detach the current controls from the specified dom element.
  48962. */
  48963. detachControl(): void;
  48964. /**
  48965. * Gets the class name of the current input.
  48966. * @returns the class name
  48967. */
  48968. getClassName(): string;
  48969. /**
  48970. * Get the friendly name associated with the input class.
  48971. * @returns the input friendly name
  48972. */
  48973. getSimpleName(): string;
  48974. /**
  48975. * Called on pointer POINTERDOUBLETAP event.
  48976. * Override this method to provide functionality on POINTERDOUBLETAP event.
  48977. */
  48978. protected onDoubleTap(type: string): void;
  48979. /**
  48980. * Called on pointer POINTERMOVE event if only a single touch is active.
  48981. * Override this method to provide functionality.
  48982. */
  48983. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48984. /**
  48985. * Called on pointer POINTERMOVE event if multiple touches are active.
  48986. * Override this method to provide functionality.
  48987. */
  48988. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48989. /**
  48990. * Called on JS contextmenu event.
  48991. * Override this method to provide functionality.
  48992. */
  48993. protected onContextMenu(evt: PointerEvent): void;
  48994. /**
  48995. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  48996. * press.
  48997. * Override this method to provide functionality.
  48998. */
  48999. protected onButtonDown(evt: PointerEvent): void;
  49000. /**
  49001. * Called each time a new POINTERUP event occurs. Ie, for each button
  49002. * release.
  49003. * Override this method to provide functionality.
  49004. */
  49005. protected onButtonUp(evt: PointerEvent): void;
  49006. /**
  49007. * Called when window becomes inactive.
  49008. * Override this method to provide functionality.
  49009. */
  49010. protected onLostFocus(): void;
  49011. private _pointerInput;
  49012. private _observer;
  49013. private _onLostFocus;
  49014. private pointA;
  49015. private pointB;
  49016. }
  49017. }
  49018. declare module BABYLON {
  49019. /**
  49020. * Manage the pointers inputs to control an arc rotate camera.
  49021. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49022. */
  49023. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  49024. /**
  49025. * Defines the camera the input is attached to.
  49026. */
  49027. camera: ArcRotateCamera;
  49028. /**
  49029. * Gets the class name of the current input.
  49030. * @returns the class name
  49031. */
  49032. getClassName(): string;
  49033. /**
  49034. * Defines the buttons associated with the input to handle camera move.
  49035. */
  49036. buttons: number[];
  49037. /**
  49038. * Defines the pointer angular sensibility along the X axis or how fast is
  49039. * the camera rotating.
  49040. */
  49041. angularSensibilityX: number;
  49042. /**
  49043. * Defines the pointer angular sensibility along the Y axis or how fast is
  49044. * the camera rotating.
  49045. */
  49046. angularSensibilityY: number;
  49047. /**
  49048. * Defines the pointer pinch precision or how fast is the camera zooming.
  49049. */
  49050. pinchPrecision: number;
  49051. /**
  49052. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49053. * from 0.
  49054. * It defines the percentage of current camera.radius to use as delta when
  49055. * pinch zoom is used.
  49056. */
  49057. pinchDeltaPercentage: number;
  49058. /**
  49059. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49060. * that any object in the plane at the camera's target point will scale
  49061. * perfectly with finger motion.
  49062. * Overrides pinchDeltaPercentage and pinchPrecision.
  49063. */
  49064. useNaturalPinchZoom: boolean;
  49065. /**
  49066. * Defines the pointer panning sensibility or how fast is the camera moving.
  49067. */
  49068. panningSensibility: number;
  49069. /**
  49070. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49071. */
  49072. multiTouchPanning: boolean;
  49073. /**
  49074. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49075. * zoom (pinch) through multitouch.
  49076. */
  49077. multiTouchPanAndZoom: boolean;
  49078. /**
  49079. * Revers pinch action direction.
  49080. */
  49081. pinchInwards: boolean;
  49082. private _isPanClick;
  49083. private _twoFingerActivityCount;
  49084. private _isPinching;
  49085. /**
  49086. * Called on pointer POINTERMOVE event if only a single touch is active.
  49087. */
  49088. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49089. /**
  49090. * Called on pointer POINTERDOUBLETAP event.
  49091. */
  49092. protected onDoubleTap(type: string): void;
  49093. /**
  49094. * Called on pointer POINTERMOVE event if multiple touches are active.
  49095. */
  49096. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49097. /**
  49098. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49099. * press.
  49100. */
  49101. protected onButtonDown(evt: PointerEvent): void;
  49102. /**
  49103. * Called each time a new POINTERUP event occurs. Ie, for each button
  49104. * release.
  49105. */
  49106. protected onButtonUp(evt: PointerEvent): void;
  49107. /**
  49108. * Called when window becomes inactive.
  49109. */
  49110. protected onLostFocus(): void;
  49111. }
  49112. }
  49113. declare module BABYLON {
  49114. /**
  49115. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49116. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49117. */
  49118. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49119. /**
  49120. * Defines the camera the input is attached to.
  49121. */
  49122. camera: ArcRotateCamera;
  49123. /**
  49124. * Defines the list of key codes associated with the up action (increase alpha)
  49125. */
  49126. keysUp: number[];
  49127. /**
  49128. * Defines the list of key codes associated with the down action (decrease alpha)
  49129. */
  49130. keysDown: number[];
  49131. /**
  49132. * Defines the list of key codes associated with the left action (increase beta)
  49133. */
  49134. keysLeft: number[];
  49135. /**
  49136. * Defines the list of key codes associated with the right action (decrease beta)
  49137. */
  49138. keysRight: number[];
  49139. /**
  49140. * Defines the list of key codes associated with the reset action.
  49141. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49142. */
  49143. keysReset: number[];
  49144. /**
  49145. * Defines the panning sensibility of the inputs.
  49146. * (How fast is the camera panning)
  49147. */
  49148. panningSensibility: number;
  49149. /**
  49150. * Defines the zooming sensibility of the inputs.
  49151. * (How fast is the camera zooming)
  49152. */
  49153. zoomingSensibility: number;
  49154. /**
  49155. * Defines whether maintaining the alt key down switch the movement mode from
  49156. * orientation to zoom.
  49157. */
  49158. useAltToZoom: boolean;
  49159. /**
  49160. * Rotation speed of the camera
  49161. */
  49162. angularSpeed: number;
  49163. private _keys;
  49164. private _ctrlPressed;
  49165. private _altPressed;
  49166. private _onCanvasBlurObserver;
  49167. private _onKeyboardObserver;
  49168. private _engine;
  49169. private _scene;
  49170. /**
  49171. * Attach the input controls to a specific dom element to get the input from.
  49172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49173. */
  49174. attachControl(noPreventDefault?: boolean): void;
  49175. /**
  49176. * Detach the current controls from the specified dom element.
  49177. */
  49178. detachControl(): void;
  49179. /**
  49180. * Update the current camera state depending on the inputs that have been used this frame.
  49181. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49182. */
  49183. checkInputs(): void;
  49184. /**
  49185. * Gets the class name of the current intput.
  49186. * @returns the class name
  49187. */
  49188. getClassName(): string;
  49189. /**
  49190. * Get the friendly name associated with the input class.
  49191. * @returns the input friendly name
  49192. */
  49193. getSimpleName(): string;
  49194. }
  49195. }
  49196. declare module BABYLON {
  49197. /**
  49198. * Manage the mouse wheel inputs to control an arc rotate camera.
  49199. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49200. */
  49201. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49202. /**
  49203. * Defines the camera the input is attached to.
  49204. */
  49205. camera: ArcRotateCamera;
  49206. /**
  49207. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49208. */
  49209. wheelPrecision: number;
  49210. /**
  49211. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49212. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49213. */
  49214. wheelDeltaPercentage: number;
  49215. private _wheel;
  49216. private _observer;
  49217. private computeDeltaFromMouseWheelLegacyEvent;
  49218. /**
  49219. * Attach the input controls to a specific dom element to get the input from.
  49220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49221. */
  49222. attachControl(noPreventDefault?: boolean): void;
  49223. /**
  49224. * Detach the current controls from the specified dom element.
  49225. */
  49226. detachControl(): void;
  49227. /**
  49228. * Gets the class name of the current intput.
  49229. * @returns the class name
  49230. */
  49231. getClassName(): string;
  49232. /**
  49233. * Get the friendly name associated with the input class.
  49234. * @returns the input friendly name
  49235. */
  49236. getSimpleName(): string;
  49237. }
  49238. }
  49239. declare module BABYLON {
  49240. /**
  49241. * Default Inputs manager for the ArcRotateCamera.
  49242. * It groups all the default supported inputs for ease of use.
  49243. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49244. */
  49245. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49246. /**
  49247. * Instantiates a new ArcRotateCameraInputsManager.
  49248. * @param camera Defines the camera the inputs belong to
  49249. */
  49250. constructor(camera: ArcRotateCamera);
  49251. /**
  49252. * Add mouse wheel input support to the input manager.
  49253. * @returns the current input manager
  49254. */
  49255. addMouseWheel(): ArcRotateCameraInputsManager;
  49256. /**
  49257. * Add pointers input support to the input manager.
  49258. * @returns the current input manager
  49259. */
  49260. addPointers(): ArcRotateCameraInputsManager;
  49261. /**
  49262. * Add keyboard input support to the input manager.
  49263. * @returns the current input manager
  49264. */
  49265. addKeyboard(): ArcRotateCameraInputsManager;
  49266. }
  49267. }
  49268. declare module BABYLON {
  49269. /**
  49270. * This represents an orbital type of camera.
  49271. *
  49272. * 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.
  49273. * 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.
  49274. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49275. */
  49276. export class ArcRotateCamera extends TargetCamera {
  49277. /**
  49278. * Defines the rotation angle of the camera along the longitudinal axis.
  49279. */
  49280. alpha: number;
  49281. /**
  49282. * Defines the rotation angle of the camera along the latitudinal axis.
  49283. */
  49284. beta: number;
  49285. /**
  49286. * Defines the radius of the camera from it s target point.
  49287. */
  49288. radius: number;
  49289. protected _target: Vector3;
  49290. protected _targetHost: Nullable<AbstractMesh>;
  49291. /**
  49292. * Defines the target point of the camera.
  49293. * The camera looks towards it form the radius distance.
  49294. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  49295. */
  49296. get target(): Vector3;
  49297. set target(value: Vector3);
  49298. /**
  49299. * Define the current local position of the camera in the scene
  49300. */
  49301. get position(): Vector3;
  49302. set position(newPosition: Vector3);
  49303. protected _upToYMatrix: Matrix;
  49304. protected _YToUpMatrix: Matrix;
  49305. /**
  49306. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  49307. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  49308. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  49309. */
  49310. set upVector(vec: Vector3);
  49311. get upVector(): Vector3;
  49312. /**
  49313. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  49314. */
  49315. setMatUp(): void;
  49316. /**
  49317. * Current inertia value on the longitudinal axis.
  49318. * The bigger this number the longer it will take for the camera to stop.
  49319. */
  49320. inertialAlphaOffset: number;
  49321. /**
  49322. * Current inertia value on the latitudinal axis.
  49323. * The bigger this number the longer it will take for the camera to stop.
  49324. */
  49325. inertialBetaOffset: number;
  49326. /**
  49327. * Current inertia value on the radius axis.
  49328. * The bigger this number the longer it will take for the camera to stop.
  49329. */
  49330. inertialRadiusOffset: number;
  49331. /**
  49332. * Minimum allowed angle on the longitudinal axis.
  49333. * This can help limiting how the Camera is able to move in the scene.
  49334. */
  49335. lowerAlphaLimit: Nullable<number>;
  49336. /**
  49337. * Maximum allowed angle on the longitudinal axis.
  49338. * This can help limiting how the Camera is able to move in the scene.
  49339. */
  49340. upperAlphaLimit: Nullable<number>;
  49341. /**
  49342. * Minimum allowed angle on the latitudinal axis.
  49343. * This can help limiting how the Camera is able to move in the scene.
  49344. */
  49345. lowerBetaLimit: number;
  49346. /**
  49347. * Maximum allowed angle on the latitudinal axis.
  49348. * This can help limiting how the Camera is able to move in the scene.
  49349. */
  49350. upperBetaLimit: number;
  49351. /**
  49352. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  49353. * This can help limiting how the Camera is able to move in the scene.
  49354. */
  49355. lowerRadiusLimit: Nullable<number>;
  49356. /**
  49357. * Maximum allowed distance of the camera to the target (The camera can not get further).
  49358. * This can help limiting how the Camera is able to move in the scene.
  49359. */
  49360. upperRadiusLimit: Nullable<number>;
  49361. /**
  49362. * Defines the current inertia value used during panning of the camera along the X axis.
  49363. */
  49364. inertialPanningX: number;
  49365. /**
  49366. * Defines the current inertia value used during panning of the camera along the Y axis.
  49367. */
  49368. inertialPanningY: number;
  49369. /**
  49370. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  49371. * Basically if your fingers moves away from more than this distance you will be considered
  49372. * in pinch mode.
  49373. */
  49374. pinchToPanMaxDistance: number;
  49375. /**
  49376. * Defines the maximum distance the camera can pan.
  49377. * This could help keeping the cammera always in your scene.
  49378. */
  49379. panningDistanceLimit: Nullable<number>;
  49380. /**
  49381. * Defines the target of the camera before paning.
  49382. */
  49383. panningOriginTarget: Vector3;
  49384. /**
  49385. * Defines the value of the inertia used during panning.
  49386. * 0 would mean stop inertia and one would mean no decelleration at all.
  49387. */
  49388. panningInertia: number;
  49389. /**
  49390. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  49391. */
  49392. get angularSensibilityX(): number;
  49393. set angularSensibilityX(value: number);
  49394. /**
  49395. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  49396. */
  49397. get angularSensibilityY(): number;
  49398. set angularSensibilityY(value: number);
  49399. /**
  49400. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  49401. */
  49402. get pinchPrecision(): number;
  49403. set pinchPrecision(value: number);
  49404. /**
  49405. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  49406. * It will be used instead of pinchDeltaPrecision if different from 0.
  49407. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49408. */
  49409. get pinchDeltaPercentage(): number;
  49410. set pinchDeltaPercentage(value: number);
  49411. /**
  49412. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  49413. * and pinch delta percentage.
  49414. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49415. * that any object in the plane at the camera's target point will scale
  49416. * perfectly with finger motion.
  49417. */
  49418. get useNaturalPinchZoom(): boolean;
  49419. set useNaturalPinchZoom(value: boolean);
  49420. /**
  49421. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  49422. */
  49423. get panningSensibility(): number;
  49424. set panningSensibility(value: number);
  49425. /**
  49426. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  49427. */
  49428. get keysUp(): number[];
  49429. set keysUp(value: number[]);
  49430. /**
  49431. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  49432. */
  49433. get keysDown(): number[];
  49434. set keysDown(value: number[]);
  49435. /**
  49436. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  49437. */
  49438. get keysLeft(): number[];
  49439. set keysLeft(value: number[]);
  49440. /**
  49441. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  49442. */
  49443. get keysRight(): number[];
  49444. set keysRight(value: number[]);
  49445. /**
  49446. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49447. */
  49448. get wheelPrecision(): number;
  49449. set wheelPrecision(value: number);
  49450. /**
  49451. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  49452. * It will be used instead of pinchDeltaPrecision if different from 0.
  49453. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49454. */
  49455. get wheelDeltaPercentage(): number;
  49456. set wheelDeltaPercentage(value: number);
  49457. /**
  49458. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  49459. */
  49460. zoomOnFactor: number;
  49461. /**
  49462. * Defines a screen offset for the camera position.
  49463. */
  49464. targetScreenOffset: Vector2;
  49465. /**
  49466. * Allows the camera to be completely reversed.
  49467. * If false the camera can not arrive upside down.
  49468. */
  49469. allowUpsideDown: boolean;
  49470. /**
  49471. * Define if double tap/click is used to restore the previously saved state of the camera.
  49472. */
  49473. useInputToRestoreState: boolean;
  49474. /** @hidden */
  49475. _viewMatrix: Matrix;
  49476. /** @hidden */
  49477. _useCtrlForPanning: boolean;
  49478. /** @hidden */
  49479. _panningMouseButton: number;
  49480. /**
  49481. * Defines the input associated to the camera.
  49482. */
  49483. inputs: ArcRotateCameraInputsManager;
  49484. /** @hidden */
  49485. _reset: () => void;
  49486. /**
  49487. * Defines the allowed panning axis.
  49488. */
  49489. panningAxis: Vector3;
  49490. protected _transformedDirection: Vector3;
  49491. private _bouncingBehavior;
  49492. /**
  49493. * Gets the bouncing behavior of the camera if it has been enabled.
  49494. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49495. */
  49496. get bouncingBehavior(): Nullable<BouncingBehavior>;
  49497. /**
  49498. * Defines if the bouncing behavior of the camera is enabled on the camera.
  49499. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49500. */
  49501. get useBouncingBehavior(): boolean;
  49502. set useBouncingBehavior(value: boolean);
  49503. private _framingBehavior;
  49504. /**
  49505. * Gets the framing behavior of the camera if it has been enabled.
  49506. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49507. */
  49508. get framingBehavior(): Nullable<FramingBehavior>;
  49509. /**
  49510. * Defines if the framing behavior of the camera is enabled on the camera.
  49511. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49512. */
  49513. get useFramingBehavior(): boolean;
  49514. set useFramingBehavior(value: boolean);
  49515. private _autoRotationBehavior;
  49516. /**
  49517. * Gets the auto rotation behavior of the camera if it has been enabled.
  49518. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49519. */
  49520. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  49521. /**
  49522. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  49523. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49524. */
  49525. get useAutoRotationBehavior(): boolean;
  49526. set useAutoRotationBehavior(value: boolean);
  49527. /**
  49528. * Observable triggered when the mesh target has been changed on the camera.
  49529. */
  49530. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  49531. /**
  49532. * Event raised when the camera is colliding with a mesh.
  49533. */
  49534. onCollide: (collidedMesh: AbstractMesh) => void;
  49535. /**
  49536. * Defines whether the camera should check collision with the objects oh the scene.
  49537. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  49538. */
  49539. checkCollisions: boolean;
  49540. /**
  49541. * Defines the collision radius of the camera.
  49542. * This simulates a sphere around the camera.
  49543. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49544. */
  49545. collisionRadius: Vector3;
  49546. protected _collider: Collider;
  49547. protected _previousPosition: Vector3;
  49548. protected _collisionVelocity: Vector3;
  49549. protected _newPosition: Vector3;
  49550. protected _previousAlpha: number;
  49551. protected _previousBeta: number;
  49552. protected _previousRadius: number;
  49553. protected _collisionTriggered: boolean;
  49554. protected _targetBoundingCenter: Nullable<Vector3>;
  49555. private _computationVector;
  49556. /**
  49557. * Instantiates a new ArcRotateCamera in a given scene
  49558. * @param name Defines the name of the camera
  49559. * @param alpha Defines the camera rotation along the logitudinal axis
  49560. * @param beta Defines the camera rotation along the latitudinal axis
  49561. * @param radius Defines the camera distance from its target
  49562. * @param target Defines the camera target
  49563. * @param scene Defines the scene the camera belongs to
  49564. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  49565. */
  49566. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49567. /** @hidden */
  49568. _initCache(): void;
  49569. /** @hidden */
  49570. _updateCache(ignoreParentClass?: boolean): void;
  49571. protected _getTargetPosition(): Vector3;
  49572. private _storedAlpha;
  49573. private _storedBeta;
  49574. private _storedRadius;
  49575. private _storedTarget;
  49576. private _storedTargetScreenOffset;
  49577. /**
  49578. * Stores the current state of the camera (alpha, beta, radius and target)
  49579. * @returns the camera itself
  49580. */
  49581. storeState(): Camera;
  49582. /**
  49583. * @hidden
  49584. * Restored camera state. You must call storeState() first
  49585. */
  49586. _restoreStateValues(): boolean;
  49587. /** @hidden */
  49588. _isSynchronizedViewMatrix(): boolean;
  49589. /**
  49590. * Attach the input controls to a specific dom element to get the input from.
  49591. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49592. */
  49593. attachControl(noPreventDefault?: boolean): void;
  49594. /**
  49595. * Attach the input controls to a specific dom element to get the input from.
  49596. * @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
  49597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49598. */
  49599. attachControl(ignored: any, noPreventDefault?: boolean): void;
  49600. /**
  49601. * Attached controls to the current camera.
  49602. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49603. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49604. */
  49605. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49606. /**
  49607. * Attached controls to the current camera.
  49608. * @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
  49609. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49610. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49611. */
  49612. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49613. /**
  49614. * Attached controls to the current camera.
  49615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49616. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49617. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  49618. */
  49619. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  49620. /**
  49621. * Detach the current controls from the specified dom element.
  49622. */
  49623. detachControl(): void;
  49624. /**
  49625. * Detach the current controls from the specified dom element.
  49626. * @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
  49627. */
  49628. detachControl(ignored: any): void;
  49629. /** @hidden */
  49630. _checkInputs(): void;
  49631. protected _checkLimits(): void;
  49632. /**
  49633. * Rebuilds angles (alpha, beta) and radius from the give position and target
  49634. */
  49635. rebuildAnglesAndRadius(): void;
  49636. /**
  49637. * Use a position to define the current camera related information like alpha, beta and radius
  49638. * @param position Defines the position to set the camera at
  49639. */
  49640. setPosition(position: Vector3): void;
  49641. /**
  49642. * Defines the target the camera should look at.
  49643. * This will automatically adapt alpha beta and radius to fit within the new target.
  49644. * @param target Defines the new target as a Vector or a mesh
  49645. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  49646. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  49647. */
  49648. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  49649. /** @hidden */
  49650. _getViewMatrix(): Matrix;
  49651. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  49652. /**
  49653. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  49654. * @param meshes Defines the mesh to zoom on
  49655. * @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)
  49656. */
  49657. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  49658. /**
  49659. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  49660. * The target will be changed but the radius
  49661. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  49662. * @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)
  49663. */
  49664. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  49665. min: Vector3;
  49666. max: Vector3;
  49667. distance: number;
  49668. }, doNotUpdateMaxZ?: boolean): void;
  49669. /**
  49670. * @override
  49671. * Override Camera.createRigCamera
  49672. */
  49673. createRigCamera(name: string, cameraIndex: number): Camera;
  49674. /**
  49675. * @hidden
  49676. * @override
  49677. * Override Camera._updateRigCameras
  49678. */
  49679. _updateRigCameras(): void;
  49680. /**
  49681. * Destroy the camera and release the current resources hold by it.
  49682. */
  49683. dispose(): void;
  49684. /**
  49685. * Gets the current object class name.
  49686. * @return the class name
  49687. */
  49688. getClassName(): string;
  49689. }
  49690. }
  49691. declare module BABYLON {
  49692. /**
  49693. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  49694. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49695. */
  49696. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  49697. /**
  49698. * Gets the name of the behavior.
  49699. */
  49700. get name(): string;
  49701. private _zoomStopsAnimation;
  49702. private _idleRotationSpeed;
  49703. private _idleRotationWaitTime;
  49704. private _idleRotationSpinupTime;
  49705. /**
  49706. * Sets the flag that indicates if user zooming should stop animation.
  49707. */
  49708. set zoomStopsAnimation(flag: boolean);
  49709. /**
  49710. * Gets the flag that indicates if user zooming should stop animation.
  49711. */
  49712. get zoomStopsAnimation(): boolean;
  49713. /**
  49714. * Sets the default speed at which the camera rotates around the model.
  49715. */
  49716. set idleRotationSpeed(speed: number);
  49717. /**
  49718. * Gets the default speed at which the camera rotates around the model.
  49719. */
  49720. get idleRotationSpeed(): number;
  49721. /**
  49722. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  49723. */
  49724. set idleRotationWaitTime(time: number);
  49725. /**
  49726. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  49727. */
  49728. get idleRotationWaitTime(): number;
  49729. /**
  49730. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49731. */
  49732. set idleRotationSpinupTime(time: number);
  49733. /**
  49734. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49735. */
  49736. get idleRotationSpinupTime(): number;
  49737. /**
  49738. * Gets a value indicating if the camera is currently rotating because of this behavior
  49739. */
  49740. get rotationInProgress(): boolean;
  49741. private _onPrePointerObservableObserver;
  49742. private _onAfterCheckInputsObserver;
  49743. private _attachedCamera;
  49744. private _isPointerDown;
  49745. private _lastFrameTime;
  49746. private _lastInteractionTime;
  49747. private _cameraRotationSpeed;
  49748. /**
  49749. * Initializes the behavior.
  49750. */
  49751. init(): void;
  49752. /**
  49753. * Attaches the behavior to its arc rotate camera.
  49754. * @param camera Defines the camera to attach the behavior to
  49755. */
  49756. attach(camera: ArcRotateCamera): void;
  49757. /**
  49758. * Detaches the behavior from its current arc rotate camera.
  49759. */
  49760. detach(): void;
  49761. /**
  49762. * Returns true if user is scrolling.
  49763. * @return true if user is scrolling.
  49764. */
  49765. private _userIsZooming;
  49766. private _lastFrameRadius;
  49767. private _shouldAnimationStopForInteraction;
  49768. /**
  49769. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49770. */
  49771. private _applyUserInteraction;
  49772. private _userIsMoving;
  49773. }
  49774. }
  49775. declare module BABYLON {
  49776. /**
  49777. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  49778. */
  49779. export class AttachToBoxBehavior implements Behavior<Mesh> {
  49780. private ui;
  49781. /**
  49782. * The name of the behavior
  49783. */
  49784. name: string;
  49785. /**
  49786. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  49787. */
  49788. distanceAwayFromFace: number;
  49789. /**
  49790. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  49791. */
  49792. distanceAwayFromBottomOfFace: number;
  49793. private _faceVectors;
  49794. private _target;
  49795. private _scene;
  49796. private _onRenderObserver;
  49797. private _tmpMatrix;
  49798. private _tmpVector;
  49799. /**
  49800. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  49801. * @param ui The transform node that should be attched to the mesh
  49802. */
  49803. constructor(ui: TransformNode);
  49804. /**
  49805. * Initializes the behavior
  49806. */
  49807. init(): void;
  49808. private _closestFace;
  49809. private _zeroVector;
  49810. private _lookAtTmpMatrix;
  49811. private _lookAtToRef;
  49812. /**
  49813. * Attaches the AttachToBoxBehavior to the passed in mesh
  49814. * @param target The mesh that the specified node will be attached to
  49815. */
  49816. attach(target: Mesh): void;
  49817. /**
  49818. * Detaches the behavior from the mesh
  49819. */
  49820. detach(): void;
  49821. }
  49822. }
  49823. declare module BABYLON {
  49824. /**
  49825. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  49826. */
  49827. export class FadeInOutBehavior implements Behavior<Mesh> {
  49828. /**
  49829. * Time in milliseconds to delay before fading in (Default: 0)
  49830. */
  49831. delay: number;
  49832. /**
  49833. * Time in milliseconds for the mesh to fade in (Default: 300)
  49834. */
  49835. fadeInTime: number;
  49836. private _millisecondsPerFrame;
  49837. private _hovered;
  49838. private _hoverValue;
  49839. private _ownerNode;
  49840. /**
  49841. * Instatiates the FadeInOutBehavior
  49842. */
  49843. constructor();
  49844. /**
  49845. * The name of the behavior
  49846. */
  49847. get name(): string;
  49848. /**
  49849. * Initializes the behavior
  49850. */
  49851. init(): void;
  49852. /**
  49853. * Attaches the fade behavior on the passed in mesh
  49854. * @param ownerNode The mesh that will be faded in/out once attached
  49855. */
  49856. attach(ownerNode: Mesh): void;
  49857. /**
  49858. * Detaches the behavior from the mesh
  49859. */
  49860. detach(): void;
  49861. /**
  49862. * Triggers the mesh to begin fading in or out
  49863. * @param value if the object should fade in or out (true to fade in)
  49864. */
  49865. fadeIn(value: boolean): void;
  49866. private _update;
  49867. private _setAllVisibility;
  49868. }
  49869. }
  49870. declare module BABYLON {
  49871. /**
  49872. * Class containing a set of static utilities functions for managing Pivots
  49873. * @hidden
  49874. */
  49875. export class PivotTools {
  49876. private static _PivotCached;
  49877. private static _OldPivotPoint;
  49878. private static _PivotTranslation;
  49879. private static _PivotTmpVector;
  49880. private static _PivotPostMultiplyPivotMatrix;
  49881. /** @hidden */
  49882. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  49883. /** @hidden */
  49884. static _RestorePivotPoint(mesh: AbstractMesh): void;
  49885. }
  49886. }
  49887. declare module BABYLON {
  49888. /**
  49889. * Class containing static functions to help procedurally build meshes
  49890. */
  49891. export class PlaneBuilder {
  49892. /**
  49893. * Creates a plane mesh
  49894. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49895. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49896. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49898. * * 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
  49899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49900. * @param name defines the name of the mesh
  49901. * @param options defines the options used to create the mesh
  49902. * @param scene defines the hosting scene
  49903. * @returns the plane mesh
  49904. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49905. */
  49906. static CreatePlane(name: string, options: {
  49907. size?: number;
  49908. width?: number;
  49909. height?: number;
  49910. sideOrientation?: number;
  49911. frontUVs?: Vector4;
  49912. backUVs?: Vector4;
  49913. updatable?: boolean;
  49914. sourcePlane?: Plane;
  49915. }, scene?: Nullable<Scene>): Mesh;
  49916. }
  49917. }
  49918. declare module BABYLON {
  49919. /**
  49920. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  49921. */
  49922. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  49923. private static _AnyMouseID;
  49924. /**
  49925. * Abstract mesh the behavior is set on
  49926. */
  49927. attachedNode: AbstractMesh;
  49928. private _dragPlane;
  49929. private _scene;
  49930. private _pointerObserver;
  49931. private _beforeRenderObserver;
  49932. private static _planeScene;
  49933. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  49934. /**
  49935. * 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)
  49936. */
  49937. maxDragAngle: number;
  49938. /**
  49939. * @hidden
  49940. */
  49941. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  49942. /**
  49943. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  49944. */
  49945. currentDraggingPointerID: number;
  49946. /**
  49947. * The last position where the pointer hit the drag plane in world space
  49948. */
  49949. lastDragPosition: Vector3;
  49950. /**
  49951. * If the behavior is currently in a dragging state
  49952. */
  49953. dragging: boolean;
  49954. /**
  49955. * 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)
  49956. */
  49957. dragDeltaRatio: number;
  49958. /**
  49959. * If the drag plane orientation should be updated during the dragging (Default: true)
  49960. */
  49961. updateDragPlane: boolean;
  49962. private _debugMode;
  49963. private _moving;
  49964. /**
  49965. * Fires each time the attached mesh is dragged with the pointer
  49966. * * delta between last drag position and current drag position in world space
  49967. * * dragDistance along the drag axis
  49968. * * dragPlaneNormal normal of the current drag plane used during the drag
  49969. * * dragPlanePoint in world space where the drag intersects the drag plane
  49970. */
  49971. onDragObservable: Observable<{
  49972. delta: Vector3;
  49973. dragPlanePoint: Vector3;
  49974. dragPlaneNormal: Vector3;
  49975. dragDistance: number;
  49976. pointerId: number;
  49977. }>;
  49978. /**
  49979. * Fires each time a drag begins (eg. mouse down on mesh)
  49980. */
  49981. onDragStartObservable: Observable<{
  49982. dragPlanePoint: Vector3;
  49983. pointerId: number;
  49984. }>;
  49985. /**
  49986. * Fires each time a drag ends (eg. mouse release after drag)
  49987. */
  49988. onDragEndObservable: Observable<{
  49989. dragPlanePoint: Vector3;
  49990. pointerId: number;
  49991. }>;
  49992. /**
  49993. * If the attached mesh should be moved when dragged
  49994. */
  49995. moveAttached: boolean;
  49996. /**
  49997. * If the drag behavior will react to drag events (Default: true)
  49998. */
  49999. enabled: boolean;
  50000. /**
  50001. * If pointer events should start and release the drag (Default: true)
  50002. */
  50003. startAndReleaseDragOnPointerEvents: boolean;
  50004. /**
  50005. * If camera controls should be detached during the drag
  50006. */
  50007. detachCameraControls: boolean;
  50008. /**
  50009. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  50010. */
  50011. useObjectOrientationForDragging: boolean;
  50012. private _options;
  50013. /**
  50014. * Gets the options used by the behavior
  50015. */
  50016. get options(): {
  50017. dragAxis?: Vector3;
  50018. dragPlaneNormal?: Vector3;
  50019. };
  50020. /**
  50021. * Sets the options used by the behavior
  50022. */
  50023. set options(options: {
  50024. dragAxis?: Vector3;
  50025. dragPlaneNormal?: Vector3;
  50026. });
  50027. /**
  50028. * Creates a pointer drag behavior that can be attached to a mesh
  50029. * @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)
  50030. */
  50031. constructor(options?: {
  50032. dragAxis?: Vector3;
  50033. dragPlaneNormal?: Vector3;
  50034. });
  50035. /**
  50036. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50037. */
  50038. validateDrag: (targetPosition: Vector3) => boolean;
  50039. /**
  50040. * The name of the behavior
  50041. */
  50042. get name(): string;
  50043. /**
  50044. * Initializes the behavior
  50045. */
  50046. init(): void;
  50047. private _tmpVector;
  50048. private _alternatePickedPoint;
  50049. private _worldDragAxis;
  50050. private _targetPosition;
  50051. private _attachedToElement;
  50052. /**
  50053. * Attaches the drag behavior the passed in mesh
  50054. * @param ownerNode The mesh that will be dragged around once attached
  50055. * @param predicate Predicate to use for pick filtering
  50056. */
  50057. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50058. /**
  50059. * Force relase the drag action by code.
  50060. */
  50061. releaseDrag(): void;
  50062. private _startDragRay;
  50063. private _lastPointerRay;
  50064. /**
  50065. * Simulates the start of a pointer drag event on the behavior
  50066. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50067. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50068. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50069. */
  50070. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50071. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50072. private _dragDelta;
  50073. protected _moveDrag(ray: Ray): void;
  50074. private _pickWithRayOnDragPlane;
  50075. private _pointA;
  50076. private _pointC;
  50077. private _localAxis;
  50078. private _lookAt;
  50079. private _updateDragPlanePosition;
  50080. /**
  50081. * Detaches the behavior from the mesh
  50082. */
  50083. detach(): void;
  50084. }
  50085. }
  50086. declare module BABYLON {
  50087. /**
  50088. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50089. */
  50090. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50091. private _dragBehaviorA;
  50092. private _dragBehaviorB;
  50093. private _startDistance;
  50094. private _initialScale;
  50095. private _targetScale;
  50096. private _ownerNode;
  50097. private _sceneRenderObserver;
  50098. /**
  50099. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50100. */
  50101. constructor();
  50102. /**
  50103. * The name of the behavior
  50104. */
  50105. get name(): string;
  50106. /**
  50107. * Initializes the behavior
  50108. */
  50109. init(): void;
  50110. private _getCurrentDistance;
  50111. /**
  50112. * Attaches the scale behavior the passed in mesh
  50113. * @param ownerNode The mesh that will be scaled around once attached
  50114. */
  50115. attach(ownerNode: Mesh): void;
  50116. /**
  50117. * Detaches the behavior from the mesh
  50118. */
  50119. detach(): void;
  50120. }
  50121. }
  50122. declare module BABYLON {
  50123. /**
  50124. * 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
  50125. */
  50126. export class SixDofDragBehavior implements Behavior<Mesh> {
  50127. private static _virtualScene;
  50128. private _ownerNode;
  50129. private _sceneRenderObserver;
  50130. private _scene;
  50131. private _targetPosition;
  50132. private _virtualOriginMesh;
  50133. private _virtualDragMesh;
  50134. private _pointerObserver;
  50135. private _moving;
  50136. private _startingOrientation;
  50137. private _attachedToElement;
  50138. /**
  50139. * 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)
  50140. */
  50141. private zDragFactor;
  50142. /**
  50143. * If the object should rotate to face the drag origin
  50144. */
  50145. rotateDraggedObject: boolean;
  50146. /**
  50147. * If the behavior is currently in a dragging state
  50148. */
  50149. dragging: boolean;
  50150. /**
  50151. * 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)
  50152. */
  50153. dragDeltaRatio: number;
  50154. /**
  50155. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50156. */
  50157. currentDraggingPointerID: number;
  50158. /**
  50159. * If camera controls should be detached during the drag
  50160. */
  50161. detachCameraControls: boolean;
  50162. /**
  50163. * Fires each time a drag starts
  50164. */
  50165. onDragStartObservable: Observable<{}>;
  50166. /**
  50167. * Fires each time a drag happens
  50168. */
  50169. onDragObservable: Observable<void>;
  50170. /**
  50171. * Fires each time a drag ends (eg. mouse release after drag)
  50172. */
  50173. onDragEndObservable: Observable<{}>;
  50174. /**
  50175. * 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
  50176. */
  50177. constructor();
  50178. /**
  50179. * The name of the behavior
  50180. */
  50181. get name(): string;
  50182. /**
  50183. * Initializes the behavior
  50184. */
  50185. init(): void;
  50186. /**
  50187. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50188. */
  50189. private get _pointerCamera();
  50190. /**
  50191. * Attaches the scale behavior the passed in mesh
  50192. * @param ownerNode The mesh that will be scaled around once attached
  50193. */
  50194. attach(ownerNode: Mesh): void;
  50195. /**
  50196. * Detaches the behavior from the mesh
  50197. */
  50198. detach(): void;
  50199. }
  50200. }
  50201. declare module BABYLON {
  50202. /**
  50203. * Class used to apply inverse kinematics to bones
  50204. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50205. */
  50206. export class BoneIKController {
  50207. private static _tmpVecs;
  50208. private static _tmpQuat;
  50209. private static _tmpMats;
  50210. /**
  50211. * Gets or sets the target mesh
  50212. */
  50213. targetMesh: AbstractMesh;
  50214. /** Gets or sets the mesh used as pole */
  50215. poleTargetMesh: AbstractMesh;
  50216. /**
  50217. * Gets or sets the bone used as pole
  50218. */
  50219. poleTargetBone: Nullable<Bone>;
  50220. /**
  50221. * Gets or sets the target position
  50222. */
  50223. targetPosition: Vector3;
  50224. /**
  50225. * Gets or sets the pole target position
  50226. */
  50227. poleTargetPosition: Vector3;
  50228. /**
  50229. * Gets or sets the pole target local offset
  50230. */
  50231. poleTargetLocalOffset: Vector3;
  50232. /**
  50233. * Gets or sets the pole angle
  50234. */
  50235. poleAngle: number;
  50236. /**
  50237. * Gets or sets the mesh associated with the controller
  50238. */
  50239. mesh: AbstractMesh;
  50240. /**
  50241. * 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)
  50242. */
  50243. slerpAmount: number;
  50244. private _bone1Quat;
  50245. private _bone1Mat;
  50246. private _bone2Ang;
  50247. private _bone1;
  50248. private _bone2;
  50249. private _bone1Length;
  50250. private _bone2Length;
  50251. private _maxAngle;
  50252. private _maxReach;
  50253. private _rightHandedSystem;
  50254. private _bendAxis;
  50255. private _slerping;
  50256. private _adjustRoll;
  50257. /**
  50258. * Gets or sets maximum allowed angle
  50259. */
  50260. get maxAngle(): number;
  50261. set maxAngle(value: number);
  50262. /**
  50263. * Creates a new BoneIKController
  50264. * @param mesh defines the mesh to control
  50265. * @param bone defines the bone to control
  50266. * @param options defines options to set up the controller
  50267. */
  50268. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50269. targetMesh?: AbstractMesh;
  50270. poleTargetMesh?: AbstractMesh;
  50271. poleTargetBone?: Bone;
  50272. poleTargetLocalOffset?: Vector3;
  50273. poleAngle?: number;
  50274. bendAxis?: Vector3;
  50275. maxAngle?: number;
  50276. slerpAmount?: number;
  50277. });
  50278. private _setMaxAngle;
  50279. /**
  50280. * Force the controller to update the bones
  50281. */
  50282. update(): void;
  50283. }
  50284. }
  50285. declare module BABYLON {
  50286. /**
  50287. * Class used to make a bone look toward a point in space
  50288. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50289. */
  50290. export class BoneLookController {
  50291. private static _tmpVecs;
  50292. private static _tmpQuat;
  50293. private static _tmpMats;
  50294. /**
  50295. * The target Vector3 that the bone will look at
  50296. */
  50297. target: Vector3;
  50298. /**
  50299. * The mesh that the bone is attached to
  50300. */
  50301. mesh: AbstractMesh;
  50302. /**
  50303. * The bone that will be looking to the target
  50304. */
  50305. bone: Bone;
  50306. /**
  50307. * The up axis of the coordinate system that is used when the bone is rotated
  50308. */
  50309. upAxis: Vector3;
  50310. /**
  50311. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  50312. */
  50313. upAxisSpace: Space;
  50314. /**
  50315. * Used to make an adjustment to the yaw of the bone
  50316. */
  50317. adjustYaw: number;
  50318. /**
  50319. * Used to make an adjustment to the pitch of the bone
  50320. */
  50321. adjustPitch: number;
  50322. /**
  50323. * Used to make an adjustment to the roll of the bone
  50324. */
  50325. adjustRoll: number;
  50326. /**
  50327. * 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)
  50328. */
  50329. slerpAmount: number;
  50330. private _minYaw;
  50331. private _maxYaw;
  50332. private _minPitch;
  50333. private _maxPitch;
  50334. private _minYawSin;
  50335. private _minYawCos;
  50336. private _maxYawSin;
  50337. private _maxYawCos;
  50338. private _midYawConstraint;
  50339. private _minPitchTan;
  50340. private _maxPitchTan;
  50341. private _boneQuat;
  50342. private _slerping;
  50343. private _transformYawPitch;
  50344. private _transformYawPitchInv;
  50345. private _firstFrameSkipped;
  50346. private _yawRange;
  50347. private _fowardAxis;
  50348. /**
  50349. * Gets or sets the minimum yaw angle that the bone can look to
  50350. */
  50351. get minYaw(): number;
  50352. set minYaw(value: number);
  50353. /**
  50354. * Gets or sets the maximum yaw angle that the bone can look to
  50355. */
  50356. get maxYaw(): number;
  50357. set maxYaw(value: number);
  50358. /**
  50359. * Gets or sets the minimum pitch angle that the bone can look to
  50360. */
  50361. get minPitch(): number;
  50362. set minPitch(value: number);
  50363. /**
  50364. * Gets or sets the maximum pitch angle that the bone can look to
  50365. */
  50366. get maxPitch(): number;
  50367. set maxPitch(value: number);
  50368. /**
  50369. * Create a BoneLookController
  50370. * @param mesh the mesh that the bone belongs to
  50371. * @param bone the bone that will be looking to the target
  50372. * @param target the target Vector3 to look at
  50373. * @param options optional settings:
  50374. * * maxYaw: the maximum angle the bone will yaw to
  50375. * * minYaw: the minimum angle the bone will yaw to
  50376. * * maxPitch: the maximum angle the bone will pitch to
  50377. * * minPitch: the minimum angle the bone will yaw to
  50378. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  50379. * * upAxis: the up axis of the coordinate system
  50380. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  50381. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  50382. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  50383. * * adjustYaw: used to make an adjustment to the yaw of the bone
  50384. * * adjustPitch: used to make an adjustment to the pitch of the bone
  50385. * * adjustRoll: used to make an adjustment to the roll of the bone
  50386. **/
  50387. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  50388. maxYaw?: number;
  50389. minYaw?: number;
  50390. maxPitch?: number;
  50391. minPitch?: number;
  50392. slerpAmount?: number;
  50393. upAxis?: Vector3;
  50394. upAxisSpace?: Space;
  50395. yawAxis?: Vector3;
  50396. pitchAxis?: Vector3;
  50397. adjustYaw?: number;
  50398. adjustPitch?: number;
  50399. adjustRoll?: number;
  50400. });
  50401. /**
  50402. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  50403. */
  50404. update(): void;
  50405. private _getAngleDiff;
  50406. private _getAngleBetween;
  50407. private _isAngleBetween;
  50408. }
  50409. }
  50410. declare module BABYLON {
  50411. /**
  50412. * Manage the gamepad inputs to control an arc rotate camera.
  50413. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50414. */
  50415. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  50416. /**
  50417. * Defines the camera the input is attached to.
  50418. */
  50419. camera: ArcRotateCamera;
  50420. /**
  50421. * Defines the gamepad the input is gathering event from.
  50422. */
  50423. gamepad: Nullable<Gamepad>;
  50424. /**
  50425. * Defines the gamepad rotation sensiblity.
  50426. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50427. */
  50428. gamepadRotationSensibility: number;
  50429. /**
  50430. * Defines the gamepad move sensiblity.
  50431. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50432. */
  50433. gamepadMoveSensibility: number;
  50434. private _yAxisScale;
  50435. /**
  50436. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50437. */
  50438. get invertYAxis(): boolean;
  50439. set invertYAxis(value: boolean);
  50440. private _onGamepadConnectedObserver;
  50441. private _onGamepadDisconnectedObserver;
  50442. /**
  50443. * Attach the input controls to a specific dom element to get the input from.
  50444. */
  50445. attachControl(): void;
  50446. /**
  50447. * Detach the current controls from the specified dom element.
  50448. */
  50449. detachControl(): void;
  50450. /**
  50451. * Update the current camera state depending on the inputs that have been used this frame.
  50452. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50453. */
  50454. checkInputs(): void;
  50455. /**
  50456. * Gets the class name of the current intput.
  50457. * @returns the class name
  50458. */
  50459. getClassName(): string;
  50460. /**
  50461. * Get the friendly name associated with the input class.
  50462. * @returns the input friendly name
  50463. */
  50464. getSimpleName(): string;
  50465. }
  50466. }
  50467. declare module BABYLON {
  50468. interface ArcRotateCameraInputsManager {
  50469. /**
  50470. * Add orientation input support to the input manager.
  50471. * @returns the current input manager
  50472. */
  50473. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  50474. }
  50475. /**
  50476. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  50477. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50478. */
  50479. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  50480. /**
  50481. * Defines the camera the input is attached to.
  50482. */
  50483. camera: ArcRotateCamera;
  50484. /**
  50485. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  50486. */
  50487. alphaCorrection: number;
  50488. /**
  50489. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  50490. */
  50491. gammaCorrection: number;
  50492. private _alpha;
  50493. private _gamma;
  50494. private _dirty;
  50495. private _deviceOrientationHandler;
  50496. /**
  50497. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  50498. */
  50499. constructor();
  50500. /**
  50501. * Attach the input controls to a specific dom element to get the input from.
  50502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50503. */
  50504. attachControl(noPreventDefault?: boolean): void;
  50505. /** @hidden */
  50506. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  50507. /**
  50508. * Update the current camera state depending on the inputs that have been used this frame.
  50509. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50510. */
  50511. checkInputs(): void;
  50512. /**
  50513. * Detach the current controls from the specified dom element.
  50514. */
  50515. detachControl(): void;
  50516. /**
  50517. * Gets the class name of the current intput.
  50518. * @returns the class name
  50519. */
  50520. getClassName(): string;
  50521. /**
  50522. * Get the friendly name associated with the input class.
  50523. * @returns the input friendly name
  50524. */
  50525. getSimpleName(): string;
  50526. }
  50527. }
  50528. declare module BABYLON {
  50529. /**
  50530. * Listen to mouse events to control the camera.
  50531. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50532. */
  50533. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  50534. /**
  50535. * Defines the camera the input is attached to.
  50536. */
  50537. camera: FlyCamera;
  50538. /**
  50539. * Defines if touch is enabled. (Default is true.)
  50540. */
  50541. touchEnabled: boolean;
  50542. /**
  50543. * Defines the buttons associated with the input to handle camera rotation.
  50544. */
  50545. buttons: number[];
  50546. /**
  50547. * Assign buttons for Yaw control.
  50548. */
  50549. buttonsYaw: number[];
  50550. /**
  50551. * Assign buttons for Pitch control.
  50552. */
  50553. buttonsPitch: number[];
  50554. /**
  50555. * Assign buttons for Roll control.
  50556. */
  50557. buttonsRoll: number[];
  50558. /**
  50559. * Detect if any button is being pressed while mouse is moved.
  50560. * -1 = Mouse locked.
  50561. * 0 = Left button.
  50562. * 1 = Middle Button.
  50563. * 2 = Right Button.
  50564. */
  50565. activeButton: number;
  50566. /**
  50567. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  50568. * Higher values reduce its sensitivity.
  50569. */
  50570. angularSensibility: number;
  50571. private _observer;
  50572. private _rollObserver;
  50573. private previousPosition;
  50574. private noPreventDefault;
  50575. private element;
  50576. /**
  50577. * Listen to mouse events to control the camera.
  50578. * @param touchEnabled Define if touch is enabled. (Default is true.)
  50579. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50580. */
  50581. constructor(touchEnabled?: boolean);
  50582. /**
  50583. * Attach the mouse control to the HTML DOM element.
  50584. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  50585. */
  50586. attachControl(noPreventDefault?: boolean): void;
  50587. /**
  50588. * Detach the current controls from the specified dom element.
  50589. */
  50590. detachControl(): void;
  50591. /**
  50592. * Gets the class name of the current input.
  50593. * @returns the class name.
  50594. */
  50595. getClassName(): string;
  50596. /**
  50597. * Get the friendly name associated with the input class.
  50598. * @returns the input's friendly name.
  50599. */
  50600. getSimpleName(): string;
  50601. private _pointerInput;
  50602. private _onMouseMove;
  50603. /**
  50604. * Rotate camera by mouse offset.
  50605. */
  50606. private rotateCamera;
  50607. }
  50608. }
  50609. declare module BABYLON {
  50610. /**
  50611. * Default Inputs manager for the FlyCamera.
  50612. * It groups all the default supported inputs for ease of use.
  50613. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50614. */
  50615. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  50616. /**
  50617. * Instantiates a new FlyCameraInputsManager.
  50618. * @param camera Defines the camera the inputs belong to.
  50619. */
  50620. constructor(camera: FlyCamera);
  50621. /**
  50622. * Add keyboard input support to the input manager.
  50623. * @returns the new FlyCameraKeyboardMoveInput().
  50624. */
  50625. addKeyboard(): FlyCameraInputsManager;
  50626. /**
  50627. * Add mouse input support to the input manager.
  50628. * @param touchEnabled Enable touch screen support.
  50629. * @returns the new FlyCameraMouseInput().
  50630. */
  50631. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  50632. }
  50633. }
  50634. declare module BABYLON {
  50635. /**
  50636. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50637. * such as in a 3D Space Shooter or a Flight Simulator.
  50638. */
  50639. export class FlyCamera extends TargetCamera {
  50640. /**
  50641. * Define the collision ellipsoid of the camera.
  50642. * This is helpful for simulating a camera body, like a player's body.
  50643. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50644. */
  50645. ellipsoid: Vector3;
  50646. /**
  50647. * Define an offset for the position of the ellipsoid around the camera.
  50648. * This can be helpful if the camera is attached away from the player's body center,
  50649. * such as at its head.
  50650. */
  50651. ellipsoidOffset: Vector3;
  50652. /**
  50653. * Enable or disable collisions of the camera with the rest of the scene objects.
  50654. */
  50655. checkCollisions: boolean;
  50656. /**
  50657. * Enable or disable gravity on the camera.
  50658. */
  50659. applyGravity: boolean;
  50660. /**
  50661. * Define the current direction the camera is moving to.
  50662. */
  50663. cameraDirection: Vector3;
  50664. /**
  50665. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  50666. * This overrides and empties cameraRotation.
  50667. */
  50668. rotationQuaternion: Quaternion;
  50669. /**
  50670. * Track Roll to maintain the wanted Rolling when looking around.
  50671. */
  50672. _trackRoll: number;
  50673. /**
  50674. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  50675. */
  50676. rollCorrect: number;
  50677. /**
  50678. * Mimic a banked turn, Rolling the camera when Yawing.
  50679. * It's recommended to use rollCorrect = 10 for faster banking correction.
  50680. */
  50681. bankedTurn: boolean;
  50682. /**
  50683. * Limit in radians for how much Roll banking will add. (Default: 90°)
  50684. */
  50685. bankedTurnLimit: number;
  50686. /**
  50687. * Value of 0 disables the banked Roll.
  50688. * Value of 1 is equal to the Yaw angle in radians.
  50689. */
  50690. bankedTurnMultiplier: number;
  50691. /**
  50692. * The inputs manager loads all the input sources, such as keyboard and mouse.
  50693. */
  50694. inputs: FlyCameraInputsManager;
  50695. /**
  50696. * Gets the input sensibility for mouse input.
  50697. * Higher values reduce sensitivity.
  50698. */
  50699. get angularSensibility(): number;
  50700. /**
  50701. * Sets the input sensibility for a mouse input.
  50702. * Higher values reduce sensitivity.
  50703. */
  50704. set angularSensibility(value: number);
  50705. /**
  50706. * Get the keys for camera movement forward.
  50707. */
  50708. get keysForward(): number[];
  50709. /**
  50710. * Set the keys for camera movement forward.
  50711. */
  50712. set keysForward(value: number[]);
  50713. /**
  50714. * Get the keys for camera movement backward.
  50715. */
  50716. get keysBackward(): number[];
  50717. set keysBackward(value: number[]);
  50718. /**
  50719. * Get the keys for camera movement up.
  50720. */
  50721. get keysUp(): number[];
  50722. /**
  50723. * Set the keys for camera movement up.
  50724. */
  50725. set keysUp(value: number[]);
  50726. /**
  50727. * Get the keys for camera movement down.
  50728. */
  50729. get keysDown(): number[];
  50730. /**
  50731. * Set the keys for camera movement down.
  50732. */
  50733. set keysDown(value: number[]);
  50734. /**
  50735. * Get the keys for camera movement left.
  50736. */
  50737. get keysLeft(): number[];
  50738. /**
  50739. * Set the keys for camera movement left.
  50740. */
  50741. set keysLeft(value: number[]);
  50742. /**
  50743. * Set the keys for camera movement right.
  50744. */
  50745. get keysRight(): number[];
  50746. /**
  50747. * Set the keys for camera movement right.
  50748. */
  50749. set keysRight(value: number[]);
  50750. /**
  50751. * Event raised when the camera collides with a mesh in the scene.
  50752. */
  50753. onCollide: (collidedMesh: AbstractMesh) => void;
  50754. private _collider;
  50755. private _needMoveForGravity;
  50756. private _oldPosition;
  50757. private _diffPosition;
  50758. private _newPosition;
  50759. /** @hidden */
  50760. _localDirection: Vector3;
  50761. /** @hidden */
  50762. _transformedDirection: Vector3;
  50763. /**
  50764. * Instantiates a FlyCamera.
  50765. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50766. * such as in a 3D Space Shooter or a Flight Simulator.
  50767. * @param name Define the name of the camera in the scene.
  50768. * @param position Define the starting position of the camera in the scene.
  50769. * @param scene Define the scene the camera belongs to.
  50770. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  50771. */
  50772. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50773. /**
  50774. * Attach the input controls to a specific dom element to get the input from.
  50775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50776. */
  50777. attachControl(noPreventDefault?: boolean): void;
  50778. /**
  50779. * Detach a control from the HTML DOM element.
  50780. * The camera will stop reacting to that input.
  50781. */
  50782. detachControl(): void;
  50783. private _collisionMask;
  50784. /**
  50785. * Get the mask that the camera ignores in collision events.
  50786. */
  50787. get collisionMask(): number;
  50788. /**
  50789. * Set the mask that the camera ignores in collision events.
  50790. */
  50791. set collisionMask(mask: number);
  50792. /** @hidden */
  50793. _collideWithWorld(displacement: Vector3): void;
  50794. /** @hidden */
  50795. private _onCollisionPositionChange;
  50796. /** @hidden */
  50797. _checkInputs(): void;
  50798. /** @hidden */
  50799. _decideIfNeedsToMove(): boolean;
  50800. /** @hidden */
  50801. _updatePosition(): void;
  50802. /**
  50803. * Restore the Roll to its target value at the rate specified.
  50804. * @param rate - Higher means slower restoring.
  50805. * @hidden
  50806. */
  50807. restoreRoll(rate: number): void;
  50808. /**
  50809. * Destroy the camera and release the current resources held by it.
  50810. */
  50811. dispose(): void;
  50812. /**
  50813. * Get the current object class name.
  50814. * @returns the class name.
  50815. */
  50816. getClassName(): string;
  50817. }
  50818. }
  50819. declare module BABYLON {
  50820. /**
  50821. * Listen to keyboard events to control the camera.
  50822. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50823. */
  50824. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  50825. /**
  50826. * Defines the camera the input is attached to.
  50827. */
  50828. camera: FlyCamera;
  50829. /**
  50830. * The list of keyboard keys used to control the forward move of the camera.
  50831. */
  50832. keysForward: number[];
  50833. /**
  50834. * The list of keyboard keys used to control the backward move of the camera.
  50835. */
  50836. keysBackward: number[];
  50837. /**
  50838. * The list of keyboard keys used to control the forward move of the camera.
  50839. */
  50840. keysUp: number[];
  50841. /**
  50842. * The list of keyboard keys used to control the backward move of the camera.
  50843. */
  50844. keysDown: number[];
  50845. /**
  50846. * The list of keyboard keys used to control the right strafe move of the camera.
  50847. */
  50848. keysRight: number[];
  50849. /**
  50850. * The list of keyboard keys used to control the left strafe move of the camera.
  50851. */
  50852. keysLeft: number[];
  50853. private _keys;
  50854. private _onCanvasBlurObserver;
  50855. private _onKeyboardObserver;
  50856. private _engine;
  50857. private _scene;
  50858. /**
  50859. * Attach the input controls to a specific dom element to get the input from.
  50860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50861. */
  50862. attachControl(noPreventDefault?: boolean): void;
  50863. /**
  50864. * Detach the current controls from the specified dom element.
  50865. */
  50866. detachControl(): void;
  50867. /**
  50868. * Gets the class name of the current intput.
  50869. * @returns the class name
  50870. */
  50871. getClassName(): string;
  50872. /** @hidden */
  50873. _onLostFocus(e: FocusEvent): void;
  50874. /**
  50875. * Get the friendly name associated with the input class.
  50876. * @returns the input friendly name
  50877. */
  50878. getSimpleName(): string;
  50879. /**
  50880. * Update the current camera state depending on the inputs that have been used this frame.
  50881. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50882. */
  50883. checkInputs(): void;
  50884. }
  50885. }
  50886. declare module BABYLON {
  50887. /**
  50888. * Manage the mouse wheel inputs to control a follow camera.
  50889. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50890. */
  50891. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  50892. /**
  50893. * Defines the camera the input is attached to.
  50894. */
  50895. camera: FollowCamera;
  50896. /**
  50897. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  50898. */
  50899. axisControlRadius: boolean;
  50900. /**
  50901. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  50902. */
  50903. axisControlHeight: boolean;
  50904. /**
  50905. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  50906. */
  50907. axisControlRotation: boolean;
  50908. /**
  50909. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  50910. * relation to mouseWheel events.
  50911. */
  50912. wheelPrecision: number;
  50913. /**
  50914. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  50915. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  50916. */
  50917. wheelDeltaPercentage: number;
  50918. private _wheel;
  50919. private _observer;
  50920. /**
  50921. * Attach the input controls to a specific dom element to get the input from.
  50922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50923. */
  50924. attachControl(noPreventDefault?: boolean): void;
  50925. /**
  50926. * Detach the current controls from the specified dom element.
  50927. */
  50928. detachControl(): void;
  50929. /**
  50930. * Gets the class name of the current intput.
  50931. * @returns the class name
  50932. */
  50933. getClassName(): string;
  50934. /**
  50935. * Get the friendly name associated with the input class.
  50936. * @returns the input friendly name
  50937. */
  50938. getSimpleName(): string;
  50939. }
  50940. }
  50941. declare module BABYLON {
  50942. /**
  50943. * Manage the pointers inputs to control an follow camera.
  50944. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50945. */
  50946. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  50947. /**
  50948. * Defines the camera the input is attached to.
  50949. */
  50950. camera: FollowCamera;
  50951. /**
  50952. * Gets the class name of the current input.
  50953. * @returns the class name
  50954. */
  50955. getClassName(): string;
  50956. /**
  50957. * Defines the pointer angular sensibility along the X axis or how fast is
  50958. * the camera rotating.
  50959. * A negative number will reverse the axis direction.
  50960. */
  50961. angularSensibilityX: number;
  50962. /**
  50963. * Defines the pointer angular sensibility along the Y axis or how fast is
  50964. * the camera rotating.
  50965. * A negative number will reverse the axis direction.
  50966. */
  50967. angularSensibilityY: number;
  50968. /**
  50969. * Defines the pointer pinch precision or how fast is the camera zooming.
  50970. * A negative number will reverse the axis direction.
  50971. */
  50972. pinchPrecision: number;
  50973. /**
  50974. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  50975. * from 0.
  50976. * It defines the percentage of current camera.radius to use as delta when
  50977. * pinch zoom is used.
  50978. */
  50979. pinchDeltaPercentage: number;
  50980. /**
  50981. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  50982. */
  50983. axisXControlRadius: boolean;
  50984. /**
  50985. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  50986. */
  50987. axisXControlHeight: boolean;
  50988. /**
  50989. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  50990. */
  50991. axisXControlRotation: boolean;
  50992. /**
  50993. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  50994. */
  50995. axisYControlRadius: boolean;
  50996. /**
  50997. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  50998. */
  50999. axisYControlHeight: boolean;
  51000. /**
  51001. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  51002. */
  51003. axisYControlRotation: boolean;
  51004. /**
  51005. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  51006. */
  51007. axisPinchControlRadius: boolean;
  51008. /**
  51009. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  51010. */
  51011. axisPinchControlHeight: boolean;
  51012. /**
  51013. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  51014. */
  51015. axisPinchControlRotation: boolean;
  51016. /**
  51017. * Log error messages if basic misconfiguration has occurred.
  51018. */
  51019. warningEnable: boolean;
  51020. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51021. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51022. private _warningCounter;
  51023. private _warning;
  51024. }
  51025. }
  51026. declare module BABYLON {
  51027. /**
  51028. * Default Inputs manager for the FollowCamera.
  51029. * It groups all the default supported inputs for ease of use.
  51030. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51031. */
  51032. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  51033. /**
  51034. * Instantiates a new FollowCameraInputsManager.
  51035. * @param camera Defines the camera the inputs belong to
  51036. */
  51037. constructor(camera: FollowCamera);
  51038. /**
  51039. * Add keyboard input support to the input manager.
  51040. * @returns the current input manager
  51041. */
  51042. addKeyboard(): FollowCameraInputsManager;
  51043. /**
  51044. * Add mouse wheel input support to the input manager.
  51045. * @returns the current input manager
  51046. */
  51047. addMouseWheel(): FollowCameraInputsManager;
  51048. /**
  51049. * Add pointers input support to the input manager.
  51050. * @returns the current input manager
  51051. */
  51052. addPointers(): FollowCameraInputsManager;
  51053. /**
  51054. * Add orientation input support to the input manager.
  51055. * @returns the current input manager
  51056. */
  51057. addVRDeviceOrientation(): FollowCameraInputsManager;
  51058. }
  51059. }
  51060. declare module BABYLON {
  51061. /**
  51062. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51063. * an arc rotate version arcFollowCamera are available.
  51064. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51065. */
  51066. export class FollowCamera extends TargetCamera {
  51067. /**
  51068. * Distance the follow camera should follow an object at
  51069. */
  51070. radius: number;
  51071. /**
  51072. * Minimum allowed distance of the camera to the axis of rotation
  51073. * (The camera can not get closer).
  51074. * This can help limiting how the Camera is able to move in the scene.
  51075. */
  51076. lowerRadiusLimit: Nullable<number>;
  51077. /**
  51078. * Maximum allowed distance of the camera to the axis of rotation
  51079. * (The camera can not get further).
  51080. * This can help limiting how the Camera is able to move in the scene.
  51081. */
  51082. upperRadiusLimit: Nullable<number>;
  51083. /**
  51084. * Define a rotation offset between the camera and the object it follows
  51085. */
  51086. rotationOffset: number;
  51087. /**
  51088. * Minimum allowed angle to camera position relative to target object.
  51089. * This can help limiting how the Camera is able to move in the scene.
  51090. */
  51091. lowerRotationOffsetLimit: Nullable<number>;
  51092. /**
  51093. * Maximum allowed angle to camera position relative to target object.
  51094. * This can help limiting how the Camera is able to move in the scene.
  51095. */
  51096. upperRotationOffsetLimit: Nullable<number>;
  51097. /**
  51098. * Define a height offset between the camera and the object it follows.
  51099. * It can help following an object from the top (like a car chaing a plane)
  51100. */
  51101. heightOffset: number;
  51102. /**
  51103. * Minimum allowed height of camera position relative to target object.
  51104. * This can help limiting how the Camera is able to move in the scene.
  51105. */
  51106. lowerHeightOffsetLimit: Nullable<number>;
  51107. /**
  51108. * Maximum allowed height of camera position relative to target object.
  51109. * This can help limiting how the Camera is able to move in the scene.
  51110. */
  51111. upperHeightOffsetLimit: Nullable<number>;
  51112. /**
  51113. * Define how fast the camera can accelerate to follow it s target.
  51114. */
  51115. cameraAcceleration: number;
  51116. /**
  51117. * Define the speed limit of the camera following an object.
  51118. */
  51119. maxCameraSpeed: number;
  51120. /**
  51121. * Define the target of the camera.
  51122. */
  51123. lockedTarget: Nullable<AbstractMesh>;
  51124. /**
  51125. * Defines the input associated with the camera.
  51126. */
  51127. inputs: FollowCameraInputsManager;
  51128. /**
  51129. * Instantiates the follow camera.
  51130. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51131. * @param name Define the name of the camera in the scene
  51132. * @param position Define the position of the camera
  51133. * @param scene Define the scene the camera belong to
  51134. * @param lockedTarget Define the target of the camera
  51135. */
  51136. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51137. private _follow;
  51138. /**
  51139. * Attach the input controls to a specific dom element to get the input from.
  51140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51141. */
  51142. attachControl(noPreventDefault?: boolean): void;
  51143. /**
  51144. * Detach the current controls from the specified dom element.
  51145. */
  51146. detachControl(): void;
  51147. /** @hidden */
  51148. _checkInputs(): void;
  51149. private _checkLimits;
  51150. /**
  51151. * Gets the camera class name.
  51152. * @returns the class name
  51153. */
  51154. getClassName(): string;
  51155. }
  51156. /**
  51157. * Arc Rotate version of the follow camera.
  51158. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51159. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51160. */
  51161. export class ArcFollowCamera extends TargetCamera {
  51162. /** The longitudinal angle of the camera */
  51163. alpha: number;
  51164. /** The latitudinal angle of the camera */
  51165. beta: number;
  51166. /** The radius of the camera from its target */
  51167. radius: number;
  51168. private _cartesianCoordinates;
  51169. /** Define the camera target (the mesh it should follow) */
  51170. private _meshTarget;
  51171. /**
  51172. * Instantiates a new ArcFollowCamera
  51173. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51174. * @param name Define the name of the camera
  51175. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  51176. * @param beta Define the rotation angle of the camera around the elevation axis
  51177. * @param radius Define the radius of the camera from its target point
  51178. * @param target Define the target of the camera
  51179. * @param scene Define the scene the camera belongs to
  51180. */
  51181. constructor(name: string,
  51182. /** The longitudinal angle of the camera */
  51183. alpha: number,
  51184. /** The latitudinal angle of the camera */
  51185. beta: number,
  51186. /** The radius of the camera from its target */
  51187. radius: number,
  51188. /** Define the camera target (the mesh it should follow) */
  51189. target: Nullable<AbstractMesh>, scene: Scene);
  51190. private _follow;
  51191. /** @hidden */
  51192. _checkInputs(): void;
  51193. /**
  51194. * Returns the class name of the object.
  51195. * It is mostly used internally for serialization purposes.
  51196. */
  51197. getClassName(): string;
  51198. }
  51199. }
  51200. declare module BABYLON {
  51201. /**
  51202. * Manage the keyboard inputs to control the movement of a follow camera.
  51203. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51204. */
  51205. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51206. /**
  51207. * Defines the camera the input is attached to.
  51208. */
  51209. camera: FollowCamera;
  51210. /**
  51211. * Defines the list of key codes associated with the up action (increase heightOffset)
  51212. */
  51213. keysHeightOffsetIncr: number[];
  51214. /**
  51215. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51216. */
  51217. keysHeightOffsetDecr: number[];
  51218. /**
  51219. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51220. */
  51221. keysHeightOffsetModifierAlt: boolean;
  51222. /**
  51223. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51224. */
  51225. keysHeightOffsetModifierCtrl: boolean;
  51226. /**
  51227. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51228. */
  51229. keysHeightOffsetModifierShift: boolean;
  51230. /**
  51231. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51232. */
  51233. keysRotationOffsetIncr: number[];
  51234. /**
  51235. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51236. */
  51237. keysRotationOffsetDecr: number[];
  51238. /**
  51239. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51240. */
  51241. keysRotationOffsetModifierAlt: boolean;
  51242. /**
  51243. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51244. */
  51245. keysRotationOffsetModifierCtrl: boolean;
  51246. /**
  51247. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51248. */
  51249. keysRotationOffsetModifierShift: boolean;
  51250. /**
  51251. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51252. */
  51253. keysRadiusIncr: number[];
  51254. /**
  51255. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51256. */
  51257. keysRadiusDecr: number[];
  51258. /**
  51259. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51260. */
  51261. keysRadiusModifierAlt: boolean;
  51262. /**
  51263. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51264. */
  51265. keysRadiusModifierCtrl: boolean;
  51266. /**
  51267. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51268. */
  51269. keysRadiusModifierShift: boolean;
  51270. /**
  51271. * Defines the rate of change of heightOffset.
  51272. */
  51273. heightSensibility: number;
  51274. /**
  51275. * Defines the rate of change of rotationOffset.
  51276. */
  51277. rotationSensibility: number;
  51278. /**
  51279. * Defines the rate of change of radius.
  51280. */
  51281. radiusSensibility: number;
  51282. private _keys;
  51283. private _ctrlPressed;
  51284. private _altPressed;
  51285. private _shiftPressed;
  51286. private _onCanvasBlurObserver;
  51287. private _onKeyboardObserver;
  51288. private _engine;
  51289. private _scene;
  51290. /**
  51291. * Attach the input controls to a specific dom element to get the input from.
  51292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51293. */
  51294. attachControl(noPreventDefault?: boolean): void;
  51295. /**
  51296. * Detach the current controls from the specified dom element.
  51297. */
  51298. detachControl(): void;
  51299. /**
  51300. * Update the current camera state depending on the inputs that have been used this frame.
  51301. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51302. */
  51303. checkInputs(): void;
  51304. /**
  51305. * Gets the class name of the current input.
  51306. * @returns the class name
  51307. */
  51308. getClassName(): string;
  51309. /**
  51310. * Get the friendly name associated with the input class.
  51311. * @returns the input friendly name
  51312. */
  51313. getSimpleName(): string;
  51314. /**
  51315. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51316. * allow modification of the heightOffset value.
  51317. */
  51318. private _modifierHeightOffset;
  51319. /**
  51320. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51321. * allow modification of the rotationOffset value.
  51322. */
  51323. private _modifierRotationOffset;
  51324. /**
  51325. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51326. * allow modification of the radius value.
  51327. */
  51328. private _modifierRadius;
  51329. }
  51330. }
  51331. declare module BABYLON {
  51332. interface FreeCameraInputsManager {
  51333. /**
  51334. * @hidden
  51335. */
  51336. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  51337. /**
  51338. * Add orientation input support to the input manager.
  51339. * @returns the current input manager
  51340. */
  51341. addDeviceOrientation(): FreeCameraInputsManager;
  51342. }
  51343. /**
  51344. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  51345. * Screen rotation is taken into account.
  51346. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51347. */
  51348. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  51349. private _camera;
  51350. private _screenOrientationAngle;
  51351. private _constantTranform;
  51352. private _screenQuaternion;
  51353. private _alpha;
  51354. private _beta;
  51355. private _gamma;
  51356. /**
  51357. * Can be used to detect if a device orientation sensor is available on a device
  51358. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  51359. * @returns a promise that will resolve on orientation change
  51360. */
  51361. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  51362. /**
  51363. * @hidden
  51364. */
  51365. _onDeviceOrientationChangedObservable: Observable<void>;
  51366. /**
  51367. * Instantiates a new input
  51368. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51369. */
  51370. constructor();
  51371. /**
  51372. * Define the camera controlled by the input.
  51373. */
  51374. get camera(): FreeCamera;
  51375. set camera(camera: FreeCamera);
  51376. /**
  51377. * Attach the input controls to a specific dom element to get the input from.
  51378. */
  51379. attachControl(): void;
  51380. private _orientationChanged;
  51381. private _deviceOrientation;
  51382. /**
  51383. * Detach the current controls from the specified dom element.
  51384. */
  51385. detachControl(): void;
  51386. /**
  51387. * Update the current camera state depending on the inputs that have been used this frame.
  51388. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51389. */
  51390. checkInputs(): void;
  51391. /**
  51392. * Gets the class name of the current intput.
  51393. * @returns the class name
  51394. */
  51395. getClassName(): string;
  51396. /**
  51397. * Get the friendly name associated with the input class.
  51398. * @returns the input friendly name
  51399. */
  51400. getSimpleName(): string;
  51401. }
  51402. }
  51403. declare module BABYLON {
  51404. /**
  51405. * Manage the gamepad inputs to control a free camera.
  51406. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51407. */
  51408. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  51409. /**
  51410. * Define the camera the input is attached to.
  51411. */
  51412. camera: FreeCamera;
  51413. /**
  51414. * Define the Gamepad controlling the input
  51415. */
  51416. gamepad: Nullable<Gamepad>;
  51417. /**
  51418. * Defines the gamepad rotation sensiblity.
  51419. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51420. */
  51421. gamepadAngularSensibility: number;
  51422. /**
  51423. * Defines the gamepad move sensiblity.
  51424. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51425. */
  51426. gamepadMoveSensibility: number;
  51427. private _yAxisScale;
  51428. /**
  51429. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51430. */
  51431. get invertYAxis(): boolean;
  51432. set invertYAxis(value: boolean);
  51433. private _onGamepadConnectedObserver;
  51434. private _onGamepadDisconnectedObserver;
  51435. private _cameraTransform;
  51436. private _deltaTransform;
  51437. private _vector3;
  51438. private _vector2;
  51439. /**
  51440. * Attach the input controls to a specific dom element to get the input from.
  51441. */
  51442. attachControl(): void;
  51443. /**
  51444. * Detach the current controls from the specified dom element.
  51445. */
  51446. detachControl(): void;
  51447. /**
  51448. * Update the current camera state depending on the inputs that have been used this frame.
  51449. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51450. */
  51451. checkInputs(): void;
  51452. /**
  51453. * Gets the class name of the current intput.
  51454. * @returns the class name
  51455. */
  51456. getClassName(): string;
  51457. /**
  51458. * Get the friendly name associated with the input class.
  51459. * @returns the input friendly name
  51460. */
  51461. getSimpleName(): string;
  51462. }
  51463. }
  51464. declare module BABYLON {
  51465. /**
  51466. * Defines the potential axis of a Joystick
  51467. */
  51468. export enum JoystickAxis {
  51469. /** X axis */
  51470. X = 0,
  51471. /** Y axis */
  51472. Y = 1,
  51473. /** Z axis */
  51474. Z = 2
  51475. }
  51476. /**
  51477. * Represents the different customization options available
  51478. * for VirtualJoystick
  51479. */
  51480. interface VirtualJoystickCustomizations {
  51481. /**
  51482. * Size of the joystick's puck
  51483. */
  51484. puckSize: number;
  51485. /**
  51486. * Size of the joystick's container
  51487. */
  51488. containerSize: number;
  51489. /**
  51490. * Color of the joystick && puck
  51491. */
  51492. color: string;
  51493. /**
  51494. * Image URL for the joystick's puck
  51495. */
  51496. puckImage?: string;
  51497. /**
  51498. * Image URL for the joystick's container
  51499. */
  51500. containerImage?: string;
  51501. /**
  51502. * Defines the unmoving position of the joystick container
  51503. */
  51504. position?: {
  51505. x: number;
  51506. y: number;
  51507. };
  51508. /**
  51509. * Defines whether or not the joystick container is always visible
  51510. */
  51511. alwaysVisible: boolean;
  51512. /**
  51513. * Defines whether or not to limit the movement of the puck to the joystick's container
  51514. */
  51515. limitToContainer: boolean;
  51516. }
  51517. /**
  51518. * Class used to define virtual joystick (used in touch mode)
  51519. */
  51520. export class VirtualJoystick {
  51521. /**
  51522. * Gets or sets a boolean indicating that left and right values must be inverted
  51523. */
  51524. reverseLeftRight: boolean;
  51525. /**
  51526. * Gets or sets a boolean indicating that up and down values must be inverted
  51527. */
  51528. reverseUpDown: boolean;
  51529. /**
  51530. * Gets the offset value for the position (ie. the change of the position value)
  51531. */
  51532. deltaPosition: Vector3;
  51533. /**
  51534. * Gets a boolean indicating if the virtual joystick was pressed
  51535. */
  51536. pressed: boolean;
  51537. /**
  51538. * Canvas the virtual joystick will render onto, default z-index of this is 5
  51539. */
  51540. static Canvas: Nullable<HTMLCanvasElement>;
  51541. /**
  51542. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  51543. */
  51544. limitToContainer: boolean;
  51545. private static _globalJoystickIndex;
  51546. private static _alwaysVisibleSticks;
  51547. private static vjCanvasContext;
  51548. private static vjCanvasWidth;
  51549. private static vjCanvasHeight;
  51550. private static halfWidth;
  51551. private static _GetDefaultOptions;
  51552. private _action;
  51553. private _axisTargetedByLeftAndRight;
  51554. private _axisTargetedByUpAndDown;
  51555. private _joystickSensibility;
  51556. private _inversedSensibility;
  51557. private _joystickPointerID;
  51558. private _joystickColor;
  51559. private _joystickPointerPos;
  51560. private _joystickPreviousPointerPos;
  51561. private _joystickPointerStartPos;
  51562. private _deltaJoystickVector;
  51563. private _leftJoystick;
  51564. private _touches;
  51565. private _joystickPosition;
  51566. private _alwaysVisible;
  51567. private _puckImage;
  51568. private _containerImage;
  51569. private _joystickPuckSize;
  51570. private _joystickContainerSize;
  51571. private _clearPuckSize;
  51572. private _clearContainerSize;
  51573. private _clearPuckSizeOffset;
  51574. private _clearContainerSizeOffset;
  51575. private _onPointerDownHandlerRef;
  51576. private _onPointerMoveHandlerRef;
  51577. private _onPointerUpHandlerRef;
  51578. private _onResize;
  51579. /**
  51580. * Creates a new virtual joystick
  51581. * @param leftJoystick defines that the joystick is for left hand (false by default)
  51582. * @param customizations Defines the options we want to customize the VirtualJoystick
  51583. */
  51584. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  51585. /**
  51586. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  51587. * @param newJoystickSensibility defines the new sensibility
  51588. */
  51589. setJoystickSensibility(newJoystickSensibility: number): void;
  51590. private _onPointerDown;
  51591. private _onPointerMove;
  51592. private _onPointerUp;
  51593. /**
  51594. * Change the color of the virtual joystick
  51595. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  51596. */
  51597. setJoystickColor(newColor: string): void;
  51598. /**
  51599. * Size of the joystick's container
  51600. */
  51601. set containerSize(newSize: number);
  51602. get containerSize(): number;
  51603. /**
  51604. * Size of the joystick's puck
  51605. */
  51606. set puckSize(newSize: number);
  51607. get puckSize(): number;
  51608. /**
  51609. * Clears the set position of the joystick
  51610. */
  51611. clearPosition(): void;
  51612. /**
  51613. * Defines whether or not the joystick container is always visible
  51614. */
  51615. set alwaysVisible(value: boolean);
  51616. get alwaysVisible(): boolean;
  51617. /**
  51618. * Sets the constant position of the Joystick container
  51619. * @param x X axis coordinate
  51620. * @param y Y axis coordinate
  51621. */
  51622. setPosition(x: number, y: number): void;
  51623. /**
  51624. * Defines a callback to call when the joystick is touched
  51625. * @param action defines the callback
  51626. */
  51627. setActionOnTouch(action: () => any): void;
  51628. /**
  51629. * Defines which axis you'd like to control for left & right
  51630. * @param axis defines the axis to use
  51631. */
  51632. setAxisForLeftRight(axis: JoystickAxis): void;
  51633. /**
  51634. * Defines which axis you'd like to control for up & down
  51635. * @param axis defines the axis to use
  51636. */
  51637. setAxisForUpDown(axis: JoystickAxis): void;
  51638. /**
  51639. * Clears the canvas from the previous puck / container draw
  51640. */
  51641. private _clearPreviousDraw;
  51642. /**
  51643. * Loads `urlPath` to be used for the container's image
  51644. * @param urlPath defines the urlPath of an image to use
  51645. */
  51646. setContainerImage(urlPath: string): void;
  51647. /**
  51648. * Loads `urlPath` to be used for the puck's image
  51649. * @param urlPath defines the urlPath of an image to use
  51650. */
  51651. setPuckImage(urlPath: string): void;
  51652. /**
  51653. * Draws the Virtual Joystick's container
  51654. */
  51655. private _drawContainer;
  51656. /**
  51657. * Draws the Virtual Joystick's puck
  51658. */
  51659. private _drawPuck;
  51660. private _drawVirtualJoystick;
  51661. /**
  51662. * Release internal HTML canvas
  51663. */
  51664. releaseCanvas(): void;
  51665. }
  51666. }
  51667. declare module BABYLON {
  51668. interface FreeCameraInputsManager {
  51669. /**
  51670. * Add virtual joystick input support to the input manager.
  51671. * @returns the current input manager
  51672. */
  51673. addVirtualJoystick(): FreeCameraInputsManager;
  51674. }
  51675. /**
  51676. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  51677. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51678. */
  51679. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  51680. /**
  51681. * Defines the camera the input is attached to.
  51682. */
  51683. camera: FreeCamera;
  51684. private _leftjoystick;
  51685. private _rightjoystick;
  51686. /**
  51687. * Gets the left stick of the virtual joystick.
  51688. * @returns The virtual Joystick
  51689. */
  51690. getLeftJoystick(): VirtualJoystick;
  51691. /**
  51692. * Gets the right stick of the virtual joystick.
  51693. * @returns The virtual Joystick
  51694. */
  51695. getRightJoystick(): VirtualJoystick;
  51696. /**
  51697. * Update the current camera state depending on the inputs that have been used this frame.
  51698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51699. */
  51700. checkInputs(): void;
  51701. /**
  51702. * Attach the input controls to a specific dom element to get the input from.
  51703. */
  51704. attachControl(): void;
  51705. /**
  51706. * Detach the current controls from the specified dom element.
  51707. */
  51708. detachControl(): void;
  51709. /**
  51710. * Gets the class name of the current intput.
  51711. * @returns the class name
  51712. */
  51713. getClassName(): string;
  51714. /**
  51715. * Get the friendly name associated with the input class.
  51716. * @returns the input friendly name
  51717. */
  51718. getSimpleName(): string;
  51719. }
  51720. }
  51721. declare module BABYLON {
  51722. /**
  51723. * This represents a FPS type of camera controlled by touch.
  51724. * This is like a universal camera minus the Gamepad controls.
  51725. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51726. */
  51727. export class TouchCamera extends FreeCamera {
  51728. /**
  51729. * Defines the touch sensibility for rotation.
  51730. * The higher the faster.
  51731. */
  51732. get touchAngularSensibility(): number;
  51733. set touchAngularSensibility(value: number);
  51734. /**
  51735. * Defines the touch sensibility for move.
  51736. * The higher the faster.
  51737. */
  51738. get touchMoveSensibility(): number;
  51739. set touchMoveSensibility(value: number);
  51740. /**
  51741. * Instantiates a new touch camera.
  51742. * This represents a FPS type of camera controlled by touch.
  51743. * This is like a universal camera minus the Gamepad controls.
  51744. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51745. * @param name Define the name of the camera in the scene
  51746. * @param position Define the start position of the camera in the scene
  51747. * @param scene Define the scene the camera belongs to
  51748. */
  51749. constructor(name: string, position: Vector3, scene: Scene);
  51750. /**
  51751. * Gets the current object class name.
  51752. * @return the class name
  51753. */
  51754. getClassName(): string;
  51755. /** @hidden */
  51756. _setupInputs(): void;
  51757. }
  51758. }
  51759. declare module BABYLON {
  51760. /**
  51761. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  51762. * being tilted forward or back and left or right.
  51763. */
  51764. export class DeviceOrientationCamera extends FreeCamera {
  51765. private _initialQuaternion;
  51766. private _quaternionCache;
  51767. private _tmpDragQuaternion;
  51768. private _disablePointerInputWhenUsingDeviceOrientation;
  51769. /**
  51770. * Creates a new device orientation camera
  51771. * @param name The name of the camera
  51772. * @param position The start position camera
  51773. * @param scene The scene the camera belongs to
  51774. */
  51775. constructor(name: string, position: Vector3, scene: Scene);
  51776. /**
  51777. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  51778. */
  51779. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  51780. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  51781. private _dragFactor;
  51782. /**
  51783. * Enabled turning on the y axis when the orientation sensor is active
  51784. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  51785. */
  51786. enableHorizontalDragging(dragFactor?: number): void;
  51787. /**
  51788. * Gets the current instance class name ("DeviceOrientationCamera").
  51789. * This helps avoiding instanceof at run time.
  51790. * @returns the class name
  51791. */
  51792. getClassName(): string;
  51793. /**
  51794. * @hidden
  51795. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  51796. */
  51797. _checkInputs(): void;
  51798. /**
  51799. * Reset the camera to its default orientation on the specified axis only.
  51800. * @param axis The axis to reset
  51801. */
  51802. resetToCurrentRotation(axis?: Axis): void;
  51803. }
  51804. }
  51805. declare module BABYLON {
  51806. /**
  51807. * Defines supported buttons for XBox360 compatible gamepads
  51808. */
  51809. export enum Xbox360Button {
  51810. /** A */
  51811. A = 0,
  51812. /** B */
  51813. B = 1,
  51814. /** X */
  51815. X = 2,
  51816. /** Y */
  51817. Y = 3,
  51818. /** Left button */
  51819. LB = 4,
  51820. /** Right button */
  51821. RB = 5,
  51822. /** Back */
  51823. Back = 8,
  51824. /** Start */
  51825. Start = 9,
  51826. /** Left stick */
  51827. LeftStick = 10,
  51828. /** Right stick */
  51829. RightStick = 11
  51830. }
  51831. /** Defines values for XBox360 DPad */
  51832. export enum Xbox360Dpad {
  51833. /** Up */
  51834. Up = 12,
  51835. /** Down */
  51836. Down = 13,
  51837. /** Left */
  51838. Left = 14,
  51839. /** Right */
  51840. Right = 15
  51841. }
  51842. /**
  51843. * Defines a XBox360 gamepad
  51844. */
  51845. export class Xbox360Pad extends Gamepad {
  51846. private _leftTrigger;
  51847. private _rightTrigger;
  51848. private _onlefttriggerchanged;
  51849. private _onrighttriggerchanged;
  51850. private _onbuttondown;
  51851. private _onbuttonup;
  51852. private _ondpaddown;
  51853. private _ondpadup;
  51854. /** Observable raised when a button is pressed */
  51855. onButtonDownObservable: Observable<Xbox360Button>;
  51856. /** Observable raised when a button is released */
  51857. onButtonUpObservable: Observable<Xbox360Button>;
  51858. /** Observable raised when a pad is pressed */
  51859. onPadDownObservable: Observable<Xbox360Dpad>;
  51860. /** Observable raised when a pad is released */
  51861. onPadUpObservable: Observable<Xbox360Dpad>;
  51862. private _buttonA;
  51863. private _buttonB;
  51864. private _buttonX;
  51865. private _buttonY;
  51866. private _buttonBack;
  51867. private _buttonStart;
  51868. private _buttonLB;
  51869. private _buttonRB;
  51870. private _buttonLeftStick;
  51871. private _buttonRightStick;
  51872. private _dPadUp;
  51873. private _dPadDown;
  51874. private _dPadLeft;
  51875. private _dPadRight;
  51876. private _isXboxOnePad;
  51877. /**
  51878. * Creates a new XBox360 gamepad object
  51879. * @param id defines the id of this gamepad
  51880. * @param index defines its index
  51881. * @param gamepad defines the internal HTML gamepad object
  51882. * @param xboxOne defines if it is a XBox One gamepad
  51883. */
  51884. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  51885. /**
  51886. * Defines the callback to call when left trigger is pressed
  51887. * @param callback defines the callback to use
  51888. */
  51889. onlefttriggerchanged(callback: (value: number) => void): void;
  51890. /**
  51891. * Defines the callback to call when right trigger is pressed
  51892. * @param callback defines the callback to use
  51893. */
  51894. onrighttriggerchanged(callback: (value: number) => void): void;
  51895. /**
  51896. * Gets the left trigger value
  51897. */
  51898. get leftTrigger(): number;
  51899. /**
  51900. * Sets the left trigger value
  51901. */
  51902. set leftTrigger(newValue: number);
  51903. /**
  51904. * Gets the right trigger value
  51905. */
  51906. get rightTrigger(): number;
  51907. /**
  51908. * Sets the right trigger value
  51909. */
  51910. set rightTrigger(newValue: number);
  51911. /**
  51912. * Defines the callback to call when a button is pressed
  51913. * @param callback defines the callback to use
  51914. */
  51915. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  51916. /**
  51917. * Defines the callback to call when a button is released
  51918. * @param callback defines the callback to use
  51919. */
  51920. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  51921. /**
  51922. * Defines the callback to call when a pad is pressed
  51923. * @param callback defines the callback to use
  51924. */
  51925. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  51926. /**
  51927. * Defines the callback to call when a pad is released
  51928. * @param callback defines the callback to use
  51929. */
  51930. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  51931. private _setButtonValue;
  51932. private _setDPadValue;
  51933. /**
  51934. * Gets the value of the `A` button
  51935. */
  51936. get buttonA(): number;
  51937. /**
  51938. * Sets the value of the `A` button
  51939. */
  51940. set buttonA(value: number);
  51941. /**
  51942. * Gets the value of the `B` button
  51943. */
  51944. get buttonB(): number;
  51945. /**
  51946. * Sets the value of the `B` button
  51947. */
  51948. set buttonB(value: number);
  51949. /**
  51950. * Gets the value of the `X` button
  51951. */
  51952. get buttonX(): number;
  51953. /**
  51954. * Sets the value of the `X` button
  51955. */
  51956. set buttonX(value: number);
  51957. /**
  51958. * Gets the value of the `Y` button
  51959. */
  51960. get buttonY(): number;
  51961. /**
  51962. * Sets the value of the `Y` button
  51963. */
  51964. set buttonY(value: number);
  51965. /**
  51966. * Gets the value of the `Start` button
  51967. */
  51968. get buttonStart(): number;
  51969. /**
  51970. * Sets the value of the `Start` button
  51971. */
  51972. set buttonStart(value: number);
  51973. /**
  51974. * Gets the value of the `Back` button
  51975. */
  51976. get buttonBack(): number;
  51977. /**
  51978. * Sets the value of the `Back` button
  51979. */
  51980. set buttonBack(value: number);
  51981. /**
  51982. * Gets the value of the `Left` button
  51983. */
  51984. get buttonLB(): number;
  51985. /**
  51986. * Sets the value of the `Left` button
  51987. */
  51988. set buttonLB(value: number);
  51989. /**
  51990. * Gets the value of the `Right` button
  51991. */
  51992. get buttonRB(): number;
  51993. /**
  51994. * Sets the value of the `Right` button
  51995. */
  51996. set buttonRB(value: number);
  51997. /**
  51998. * Gets the value of the Left joystick
  51999. */
  52000. get buttonLeftStick(): number;
  52001. /**
  52002. * Sets the value of the Left joystick
  52003. */
  52004. set buttonLeftStick(value: number);
  52005. /**
  52006. * Gets the value of the Right joystick
  52007. */
  52008. get buttonRightStick(): number;
  52009. /**
  52010. * Sets the value of the Right joystick
  52011. */
  52012. set buttonRightStick(value: number);
  52013. /**
  52014. * Gets the value of D-pad up
  52015. */
  52016. get dPadUp(): number;
  52017. /**
  52018. * Sets the value of D-pad up
  52019. */
  52020. set dPadUp(value: number);
  52021. /**
  52022. * Gets the value of D-pad down
  52023. */
  52024. get dPadDown(): number;
  52025. /**
  52026. * Sets the value of D-pad down
  52027. */
  52028. set dPadDown(value: number);
  52029. /**
  52030. * Gets the value of D-pad left
  52031. */
  52032. get dPadLeft(): number;
  52033. /**
  52034. * Sets the value of D-pad left
  52035. */
  52036. set dPadLeft(value: number);
  52037. /**
  52038. * Gets the value of D-pad right
  52039. */
  52040. get dPadRight(): number;
  52041. /**
  52042. * Sets the value of D-pad right
  52043. */
  52044. set dPadRight(value: number);
  52045. /**
  52046. * Force the gamepad to synchronize with device values
  52047. */
  52048. update(): void;
  52049. /**
  52050. * Disposes the gamepad
  52051. */
  52052. dispose(): void;
  52053. }
  52054. }
  52055. declare module BABYLON {
  52056. /**
  52057. * Defines supported buttons for DualShock compatible gamepads
  52058. */
  52059. export enum DualShockButton {
  52060. /** Cross */
  52061. Cross = 0,
  52062. /** Circle */
  52063. Circle = 1,
  52064. /** Square */
  52065. Square = 2,
  52066. /** Triangle */
  52067. Triangle = 3,
  52068. /** L1 */
  52069. L1 = 4,
  52070. /** R1 */
  52071. R1 = 5,
  52072. /** Share */
  52073. Share = 8,
  52074. /** Options */
  52075. Options = 9,
  52076. /** Left stick */
  52077. LeftStick = 10,
  52078. /** Right stick */
  52079. RightStick = 11
  52080. }
  52081. /** Defines values for DualShock DPad */
  52082. export enum DualShockDpad {
  52083. /** Up */
  52084. Up = 12,
  52085. /** Down */
  52086. Down = 13,
  52087. /** Left */
  52088. Left = 14,
  52089. /** Right */
  52090. Right = 15
  52091. }
  52092. /**
  52093. * Defines a DualShock gamepad
  52094. */
  52095. export class DualShockPad extends Gamepad {
  52096. private _leftTrigger;
  52097. private _rightTrigger;
  52098. private _onlefttriggerchanged;
  52099. private _onrighttriggerchanged;
  52100. private _onbuttondown;
  52101. private _onbuttonup;
  52102. private _ondpaddown;
  52103. private _ondpadup;
  52104. /** Observable raised when a button is pressed */
  52105. onButtonDownObservable: Observable<DualShockButton>;
  52106. /** Observable raised when a button is released */
  52107. onButtonUpObservable: Observable<DualShockButton>;
  52108. /** Observable raised when a pad is pressed */
  52109. onPadDownObservable: Observable<DualShockDpad>;
  52110. /** Observable raised when a pad is released */
  52111. onPadUpObservable: Observable<DualShockDpad>;
  52112. private _buttonCross;
  52113. private _buttonCircle;
  52114. private _buttonSquare;
  52115. private _buttonTriangle;
  52116. private _buttonShare;
  52117. private _buttonOptions;
  52118. private _buttonL1;
  52119. private _buttonR1;
  52120. private _buttonLeftStick;
  52121. private _buttonRightStick;
  52122. private _dPadUp;
  52123. private _dPadDown;
  52124. private _dPadLeft;
  52125. private _dPadRight;
  52126. /**
  52127. * Creates a new DualShock gamepad object
  52128. * @param id defines the id of this gamepad
  52129. * @param index defines its index
  52130. * @param gamepad defines the internal HTML gamepad object
  52131. */
  52132. constructor(id: string, index: number, gamepad: any);
  52133. /**
  52134. * Defines the callback to call when left trigger is pressed
  52135. * @param callback defines the callback to use
  52136. */
  52137. onlefttriggerchanged(callback: (value: number) => void): void;
  52138. /**
  52139. * Defines the callback to call when right trigger is pressed
  52140. * @param callback defines the callback to use
  52141. */
  52142. onrighttriggerchanged(callback: (value: number) => void): void;
  52143. /**
  52144. * Gets the left trigger value
  52145. */
  52146. get leftTrigger(): number;
  52147. /**
  52148. * Sets the left trigger value
  52149. */
  52150. set leftTrigger(newValue: number);
  52151. /**
  52152. * Gets the right trigger value
  52153. */
  52154. get rightTrigger(): number;
  52155. /**
  52156. * Sets the right trigger value
  52157. */
  52158. set rightTrigger(newValue: number);
  52159. /**
  52160. * Defines the callback to call when a button is pressed
  52161. * @param callback defines the callback to use
  52162. */
  52163. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52164. /**
  52165. * Defines the callback to call when a button is released
  52166. * @param callback defines the callback to use
  52167. */
  52168. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52169. /**
  52170. * Defines the callback to call when a pad is pressed
  52171. * @param callback defines the callback to use
  52172. */
  52173. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52174. /**
  52175. * Defines the callback to call when a pad is released
  52176. * @param callback defines the callback to use
  52177. */
  52178. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52179. private _setButtonValue;
  52180. private _setDPadValue;
  52181. /**
  52182. * Gets the value of the `Cross` button
  52183. */
  52184. get buttonCross(): number;
  52185. /**
  52186. * Sets the value of the `Cross` button
  52187. */
  52188. set buttonCross(value: number);
  52189. /**
  52190. * Gets the value of the `Circle` button
  52191. */
  52192. get buttonCircle(): number;
  52193. /**
  52194. * Sets the value of the `Circle` button
  52195. */
  52196. set buttonCircle(value: number);
  52197. /**
  52198. * Gets the value of the `Square` button
  52199. */
  52200. get buttonSquare(): number;
  52201. /**
  52202. * Sets the value of the `Square` button
  52203. */
  52204. set buttonSquare(value: number);
  52205. /**
  52206. * Gets the value of the `Triangle` button
  52207. */
  52208. get buttonTriangle(): number;
  52209. /**
  52210. * Sets the value of the `Triangle` button
  52211. */
  52212. set buttonTriangle(value: number);
  52213. /**
  52214. * Gets the value of the `Options` button
  52215. */
  52216. get buttonOptions(): number;
  52217. /**
  52218. * Sets the value of the `Options` button
  52219. */
  52220. set buttonOptions(value: number);
  52221. /**
  52222. * Gets the value of the `Share` button
  52223. */
  52224. get buttonShare(): number;
  52225. /**
  52226. * Sets the value of the `Share` button
  52227. */
  52228. set buttonShare(value: number);
  52229. /**
  52230. * Gets the value of the `L1` button
  52231. */
  52232. get buttonL1(): number;
  52233. /**
  52234. * Sets the value of the `L1` button
  52235. */
  52236. set buttonL1(value: number);
  52237. /**
  52238. * Gets the value of the `R1` button
  52239. */
  52240. get buttonR1(): number;
  52241. /**
  52242. * Sets the value of the `R1` button
  52243. */
  52244. set buttonR1(value: number);
  52245. /**
  52246. * Gets the value of the Left joystick
  52247. */
  52248. get buttonLeftStick(): number;
  52249. /**
  52250. * Sets the value of the Left joystick
  52251. */
  52252. set buttonLeftStick(value: number);
  52253. /**
  52254. * Gets the value of the Right joystick
  52255. */
  52256. get buttonRightStick(): number;
  52257. /**
  52258. * Sets the value of the Right joystick
  52259. */
  52260. set buttonRightStick(value: number);
  52261. /**
  52262. * Gets the value of D-pad up
  52263. */
  52264. get dPadUp(): number;
  52265. /**
  52266. * Sets the value of D-pad up
  52267. */
  52268. set dPadUp(value: number);
  52269. /**
  52270. * Gets the value of D-pad down
  52271. */
  52272. get dPadDown(): number;
  52273. /**
  52274. * Sets the value of D-pad down
  52275. */
  52276. set dPadDown(value: number);
  52277. /**
  52278. * Gets the value of D-pad left
  52279. */
  52280. get dPadLeft(): number;
  52281. /**
  52282. * Sets the value of D-pad left
  52283. */
  52284. set dPadLeft(value: number);
  52285. /**
  52286. * Gets the value of D-pad right
  52287. */
  52288. get dPadRight(): number;
  52289. /**
  52290. * Sets the value of D-pad right
  52291. */
  52292. set dPadRight(value: number);
  52293. /**
  52294. * Force the gamepad to synchronize with device values
  52295. */
  52296. update(): void;
  52297. /**
  52298. * Disposes the gamepad
  52299. */
  52300. dispose(): void;
  52301. }
  52302. }
  52303. declare module BABYLON {
  52304. /**
  52305. * Manager for handling gamepads
  52306. */
  52307. export class GamepadManager {
  52308. private _scene?;
  52309. private _babylonGamepads;
  52310. private _oneGamepadConnected;
  52311. /** @hidden */
  52312. _isMonitoring: boolean;
  52313. private _gamepadEventSupported;
  52314. private _gamepadSupport?;
  52315. /**
  52316. * observable to be triggered when the gamepad controller has been connected
  52317. */
  52318. onGamepadConnectedObservable: Observable<Gamepad>;
  52319. /**
  52320. * observable to be triggered when the gamepad controller has been disconnected
  52321. */
  52322. onGamepadDisconnectedObservable: Observable<Gamepad>;
  52323. private _onGamepadConnectedEvent;
  52324. private _onGamepadDisconnectedEvent;
  52325. /**
  52326. * Initializes the gamepad manager
  52327. * @param _scene BabylonJS scene
  52328. */
  52329. constructor(_scene?: Scene | undefined);
  52330. /**
  52331. * The gamepads in the game pad manager
  52332. */
  52333. get gamepads(): Gamepad[];
  52334. /**
  52335. * Get the gamepad controllers based on type
  52336. * @param type The type of gamepad controller
  52337. * @returns Nullable gamepad
  52338. */
  52339. getGamepadByType(type?: number): Nullable<Gamepad>;
  52340. /**
  52341. * Disposes the gamepad manager
  52342. */
  52343. dispose(): void;
  52344. private _addNewGamepad;
  52345. private _startMonitoringGamepads;
  52346. private _stopMonitoringGamepads;
  52347. /** @hidden */
  52348. _checkGamepadsStatus(): void;
  52349. private _updateGamepadObjects;
  52350. }
  52351. }
  52352. declare module BABYLON {
  52353. interface Scene {
  52354. /** @hidden */
  52355. _gamepadManager: Nullable<GamepadManager>;
  52356. /**
  52357. * Gets the gamepad manager associated with the scene
  52358. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  52359. */
  52360. gamepadManager: GamepadManager;
  52361. }
  52362. /**
  52363. * Interface representing a free camera inputs manager
  52364. */
  52365. interface FreeCameraInputsManager {
  52366. /**
  52367. * Adds gamepad input support to the FreeCameraInputsManager.
  52368. * @returns the FreeCameraInputsManager
  52369. */
  52370. addGamepad(): FreeCameraInputsManager;
  52371. }
  52372. /**
  52373. * Interface representing an arc rotate camera inputs manager
  52374. */
  52375. interface ArcRotateCameraInputsManager {
  52376. /**
  52377. * Adds gamepad input support to the ArcRotateCamera InputManager.
  52378. * @returns the camera inputs manager
  52379. */
  52380. addGamepad(): ArcRotateCameraInputsManager;
  52381. }
  52382. /**
  52383. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  52384. */
  52385. export class GamepadSystemSceneComponent implements ISceneComponent {
  52386. /**
  52387. * The component name helpfull to identify the component in the list of scene components.
  52388. */
  52389. readonly name: string;
  52390. /**
  52391. * The scene the component belongs to.
  52392. */
  52393. scene: Scene;
  52394. /**
  52395. * Creates a new instance of the component for the given scene
  52396. * @param scene Defines the scene to register the component in
  52397. */
  52398. constructor(scene: Scene);
  52399. /**
  52400. * Registers the component in a given scene
  52401. */
  52402. register(): void;
  52403. /**
  52404. * Rebuilds the elements related to this component in case of
  52405. * context lost for instance.
  52406. */
  52407. rebuild(): void;
  52408. /**
  52409. * Disposes the component and the associated ressources
  52410. */
  52411. dispose(): void;
  52412. private _beforeCameraUpdate;
  52413. }
  52414. }
  52415. declare module BABYLON {
  52416. /**
  52417. * 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,
  52418. * which still works and will still be found in many Playgrounds.
  52419. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52420. */
  52421. export class UniversalCamera extends TouchCamera {
  52422. /**
  52423. * Defines the gamepad rotation sensiblity.
  52424. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52425. */
  52426. get gamepadAngularSensibility(): number;
  52427. set gamepadAngularSensibility(value: number);
  52428. /**
  52429. * Defines the gamepad move sensiblity.
  52430. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52431. */
  52432. get gamepadMoveSensibility(): number;
  52433. set gamepadMoveSensibility(value: number);
  52434. /**
  52435. * 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,
  52436. * which still works and will still be found in many Playgrounds.
  52437. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52438. * @param name Define the name of the camera in the scene
  52439. * @param position Define the start position of the camera in the scene
  52440. * @param scene Define the scene the camera belongs to
  52441. */
  52442. constructor(name: string, position: Vector3, scene: Scene);
  52443. /**
  52444. * Gets the current object class name.
  52445. * @return the class name
  52446. */
  52447. getClassName(): string;
  52448. }
  52449. }
  52450. declare module BABYLON {
  52451. /**
  52452. * This represents a FPS type of camera. This is only here for back compat purpose.
  52453. * Please use the UniversalCamera instead as both are identical.
  52454. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52455. */
  52456. export class GamepadCamera extends UniversalCamera {
  52457. /**
  52458. * Instantiates a new Gamepad Camera
  52459. * This represents a FPS type of camera. This is only here for back compat purpose.
  52460. * Please use the UniversalCamera instead as both are identical.
  52461. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52462. * @param name Define the name of the camera in the scene
  52463. * @param position Define the start position of the camera in the scene
  52464. * @param scene Define the scene the camera belongs to
  52465. */
  52466. constructor(name: string, position: Vector3, scene: Scene);
  52467. /**
  52468. * Gets the current object class name.
  52469. * @return the class name
  52470. */
  52471. getClassName(): string;
  52472. }
  52473. }
  52474. declare module BABYLON {
  52475. /** @hidden */
  52476. export var anaglyphPixelShader: {
  52477. name: string;
  52478. shader: string;
  52479. };
  52480. }
  52481. declare module BABYLON {
  52482. /**
  52483. * Postprocess used to generate anaglyphic rendering
  52484. */
  52485. export class AnaglyphPostProcess extends PostProcess {
  52486. private _passedProcess;
  52487. /**
  52488. * Gets a string identifying the name of the class
  52489. * @returns "AnaglyphPostProcess" string
  52490. */
  52491. getClassName(): string;
  52492. /**
  52493. * Creates a new AnaglyphPostProcess
  52494. * @param name defines postprocess name
  52495. * @param options defines creation options or target ratio scale
  52496. * @param rigCameras defines cameras using this postprocess
  52497. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  52498. * @param engine defines hosting engine
  52499. * @param reusable defines if the postprocess will be reused multiple times per frame
  52500. */
  52501. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  52502. }
  52503. }
  52504. declare module BABYLON {
  52505. /**
  52506. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  52507. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52508. */
  52509. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  52510. /**
  52511. * Creates a new AnaglyphArcRotateCamera
  52512. * @param name defines camera name
  52513. * @param alpha defines alpha angle (in radians)
  52514. * @param beta defines beta angle (in radians)
  52515. * @param radius defines radius
  52516. * @param target defines camera target
  52517. * @param interaxialDistance defines distance between each color axis
  52518. * @param scene defines the hosting scene
  52519. */
  52520. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  52521. /**
  52522. * Gets camera class name
  52523. * @returns AnaglyphArcRotateCamera
  52524. */
  52525. getClassName(): string;
  52526. }
  52527. }
  52528. declare module BABYLON {
  52529. /**
  52530. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  52531. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52532. */
  52533. export class AnaglyphFreeCamera extends FreeCamera {
  52534. /**
  52535. * Creates a new AnaglyphFreeCamera
  52536. * @param name defines camera name
  52537. * @param position defines initial position
  52538. * @param interaxialDistance defines distance between each color axis
  52539. * @param scene defines the hosting scene
  52540. */
  52541. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52542. /**
  52543. * Gets camera class name
  52544. * @returns AnaglyphFreeCamera
  52545. */
  52546. getClassName(): string;
  52547. }
  52548. }
  52549. declare module BABYLON {
  52550. /**
  52551. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  52552. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52553. */
  52554. export class AnaglyphGamepadCamera extends GamepadCamera {
  52555. /**
  52556. * Creates a new AnaglyphGamepadCamera
  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 AnaglyphGamepadCamera
  52566. */
  52567. getClassName(): string;
  52568. }
  52569. }
  52570. declare module BABYLON {
  52571. /**
  52572. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  52573. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52574. */
  52575. export class AnaglyphUniversalCamera extends UniversalCamera {
  52576. /**
  52577. * Creates a new AnaglyphUniversalCamera
  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 AnaglyphUniversalCamera
  52587. */
  52588. getClassName(): string;
  52589. }
  52590. }
  52591. declare module BABYLON {
  52592. /**
  52593. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  52594. * @see https://doc.babylonjs.com/features/cameras
  52595. */
  52596. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  52597. /**
  52598. * Creates a new StereoscopicArcRotateCamera
  52599. * @param name defines camera name
  52600. * @param alpha defines alpha angle (in radians)
  52601. * @param beta defines beta angle (in radians)
  52602. * @param radius defines radius
  52603. * @param target defines camera target
  52604. * @param interaxialDistance defines distance between each color axis
  52605. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52606. * @param scene defines the hosting scene
  52607. */
  52608. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52609. /**
  52610. * Gets camera class name
  52611. * @returns StereoscopicArcRotateCamera
  52612. */
  52613. getClassName(): string;
  52614. }
  52615. }
  52616. declare module BABYLON {
  52617. /**
  52618. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  52619. * @see https://doc.babylonjs.com/features/cameras
  52620. */
  52621. export class StereoscopicFreeCamera extends FreeCamera {
  52622. /**
  52623. * Creates a new StereoscopicFreeCamera
  52624. * @param name defines camera name
  52625. * @param position defines initial position
  52626. * @param interaxialDistance defines distance between each color axis
  52627. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52628. * @param scene defines the hosting scene
  52629. */
  52630. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52631. /**
  52632. * Gets camera class name
  52633. * @returns StereoscopicFreeCamera
  52634. */
  52635. getClassName(): string;
  52636. }
  52637. }
  52638. declare module BABYLON {
  52639. /**
  52640. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  52641. * @see https://doc.babylonjs.com/features/cameras
  52642. */
  52643. export class StereoscopicGamepadCamera extends GamepadCamera {
  52644. /**
  52645. * Creates a new StereoscopicGamepadCamera
  52646. * @param name defines camera name
  52647. * @param position defines initial position
  52648. * @param interaxialDistance defines distance between each color axis
  52649. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52650. * @param scene defines the hosting scene
  52651. */
  52652. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52653. /**
  52654. * Gets camera class name
  52655. * @returns StereoscopicGamepadCamera
  52656. */
  52657. getClassName(): string;
  52658. }
  52659. }
  52660. declare module BABYLON {
  52661. /**
  52662. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  52663. * @see https://doc.babylonjs.com/features/cameras
  52664. */
  52665. export class StereoscopicUniversalCamera extends UniversalCamera {
  52666. /**
  52667. * Creates a new StereoscopicUniversalCamera
  52668. * @param name defines camera name
  52669. * @param position defines initial position
  52670. * @param interaxialDistance defines distance between each color axis
  52671. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52672. * @param scene defines the hosting scene
  52673. */
  52674. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52675. /**
  52676. * Gets camera class name
  52677. * @returns StereoscopicUniversalCamera
  52678. */
  52679. getClassName(): string;
  52680. }
  52681. }
  52682. declare module BABYLON {
  52683. /**
  52684. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  52685. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52686. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52687. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52688. */
  52689. export class VirtualJoysticksCamera extends FreeCamera {
  52690. /**
  52691. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  52692. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52693. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52694. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52695. * @param name Define the name of the camera in the scene
  52696. * @param position Define the start position of the camera in the scene
  52697. * @param scene Define the scene the camera belongs to
  52698. */
  52699. constructor(name: string, position: Vector3, scene: Scene);
  52700. /**
  52701. * Gets the current object class name.
  52702. * @return the class name
  52703. */
  52704. getClassName(): string;
  52705. }
  52706. }
  52707. declare module BABYLON {
  52708. /**
  52709. * This represents all the required metrics to create a VR camera.
  52710. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  52711. */
  52712. export class VRCameraMetrics {
  52713. /**
  52714. * Define the horizontal resolution off the screen.
  52715. */
  52716. hResolution: number;
  52717. /**
  52718. * Define the vertical resolution off the screen.
  52719. */
  52720. vResolution: number;
  52721. /**
  52722. * Define the horizontal screen size.
  52723. */
  52724. hScreenSize: number;
  52725. /**
  52726. * Define the vertical screen size.
  52727. */
  52728. vScreenSize: number;
  52729. /**
  52730. * Define the vertical screen center position.
  52731. */
  52732. vScreenCenter: number;
  52733. /**
  52734. * Define the distance of the eyes to the screen.
  52735. */
  52736. eyeToScreenDistance: number;
  52737. /**
  52738. * Define the distance between both lenses
  52739. */
  52740. lensSeparationDistance: number;
  52741. /**
  52742. * Define the distance between both viewer's eyes.
  52743. */
  52744. interpupillaryDistance: number;
  52745. /**
  52746. * Define the distortion factor of the VR postprocess.
  52747. * Please, touch with care.
  52748. */
  52749. distortionK: number[];
  52750. /**
  52751. * Define the chromatic aberration correction factors for the VR post process.
  52752. */
  52753. chromaAbCorrection: number[];
  52754. /**
  52755. * Define the scale factor of the post process.
  52756. * The smaller the better but the slower.
  52757. */
  52758. postProcessScaleFactor: number;
  52759. /**
  52760. * Define an offset for the lens center.
  52761. */
  52762. lensCenterOffset: number;
  52763. /**
  52764. * Define if the current vr camera should compensate the distortion of the lense or not.
  52765. */
  52766. compensateDistortion: boolean;
  52767. /**
  52768. * Defines if multiview should be enabled when rendering (Default: false)
  52769. */
  52770. multiviewEnabled: boolean;
  52771. /**
  52772. * Gets the rendering aspect ratio based on the provided resolutions.
  52773. */
  52774. get aspectRatio(): number;
  52775. /**
  52776. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  52777. */
  52778. get aspectRatioFov(): number;
  52779. /**
  52780. * @hidden
  52781. */
  52782. get leftHMatrix(): Matrix;
  52783. /**
  52784. * @hidden
  52785. */
  52786. get rightHMatrix(): Matrix;
  52787. /**
  52788. * @hidden
  52789. */
  52790. get leftPreViewMatrix(): Matrix;
  52791. /**
  52792. * @hidden
  52793. */
  52794. get rightPreViewMatrix(): Matrix;
  52795. /**
  52796. * Get the default VRMetrics based on the most generic setup.
  52797. * @returns the default vr metrics
  52798. */
  52799. static GetDefault(): VRCameraMetrics;
  52800. }
  52801. }
  52802. declare module BABYLON {
  52803. /** @hidden */
  52804. export var vrDistortionCorrectionPixelShader: {
  52805. name: string;
  52806. shader: string;
  52807. };
  52808. }
  52809. declare module BABYLON {
  52810. /**
  52811. * VRDistortionCorrectionPostProcess used for mobile VR
  52812. */
  52813. export class VRDistortionCorrectionPostProcess extends PostProcess {
  52814. private _isRightEye;
  52815. private _distortionFactors;
  52816. private _postProcessScaleFactor;
  52817. private _lensCenterOffset;
  52818. private _scaleIn;
  52819. private _scaleFactor;
  52820. private _lensCenter;
  52821. /**
  52822. * Gets a string identifying the name of the class
  52823. * @returns "VRDistortionCorrectionPostProcess" string
  52824. */
  52825. getClassName(): string;
  52826. /**
  52827. * Initializes the VRDistortionCorrectionPostProcess
  52828. * @param name The name of the effect.
  52829. * @param camera The camera to apply the render pass to.
  52830. * @param isRightEye If this is for the right eye distortion
  52831. * @param vrMetrics All the required metrics for the VR camera
  52832. */
  52833. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  52834. }
  52835. }
  52836. declare module BABYLON {
  52837. /**
  52838. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  52839. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52840. */
  52841. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  52842. /**
  52843. * Creates a new VRDeviceOrientationArcRotateCamera
  52844. * @param name defines camera name
  52845. * @param alpha defines the camera rotation along the logitudinal axis
  52846. * @param beta defines the camera rotation along the latitudinal axis
  52847. * @param radius defines the camera distance from its target
  52848. * @param target defines the camera target
  52849. * @param scene defines the scene the camera belongs to
  52850. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52851. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52852. */
  52853. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52854. /**
  52855. * Gets camera class name
  52856. * @returns VRDeviceOrientationArcRotateCamera
  52857. */
  52858. getClassName(): string;
  52859. }
  52860. }
  52861. declare module BABYLON {
  52862. /**
  52863. * Camera used to simulate VR rendering (based on FreeCamera)
  52864. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52865. */
  52866. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  52867. /**
  52868. * Creates a new VRDeviceOrientationFreeCamera
  52869. * @param name defines camera name
  52870. * @param position defines the start position of the camera
  52871. * @param scene defines the scene the camera belongs to
  52872. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52873. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52874. */
  52875. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52876. /**
  52877. * Gets camera class name
  52878. * @returns VRDeviceOrientationFreeCamera
  52879. */
  52880. getClassName(): string;
  52881. }
  52882. }
  52883. declare module BABYLON {
  52884. /**
  52885. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  52886. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52887. */
  52888. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  52889. /**
  52890. * Creates a new VRDeviceOrientationGamepadCamera
  52891. * @param name defines camera name
  52892. * @param position defines the start position of the camera
  52893. * @param scene defines the scene the camera belongs to
  52894. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52895. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52896. */
  52897. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52898. /**
  52899. * Gets camera class name
  52900. * @returns VRDeviceOrientationGamepadCamera
  52901. */
  52902. getClassName(): string;
  52903. }
  52904. }
  52905. declare module BABYLON {
  52906. /**
  52907. * A class extending Texture allowing drawing on a texture
  52908. * @see https://doc.babylonjs.com/how_to/dynamictexture
  52909. */
  52910. export class DynamicTexture extends Texture {
  52911. private _generateMipMaps;
  52912. private _canvas;
  52913. private _context;
  52914. /**
  52915. * Creates a DynamicTexture
  52916. * @param name defines the name of the texture
  52917. * @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
  52918. * @param scene defines the scene where you want the texture
  52919. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  52920. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52921. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  52922. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  52923. */
  52924. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  52925. /**
  52926. * Get the current class name of the texture useful for serialization or dynamic coding.
  52927. * @returns "DynamicTexture"
  52928. */
  52929. getClassName(): string;
  52930. /**
  52931. * Gets the current state of canRescale
  52932. */
  52933. get canRescale(): boolean;
  52934. private _recreate;
  52935. /**
  52936. * Scales the texture
  52937. * @param ratio the scale factor to apply to both width and height
  52938. */
  52939. scale(ratio: number): void;
  52940. /**
  52941. * Resizes the texture
  52942. * @param width the new width
  52943. * @param height the new height
  52944. */
  52945. scaleTo(width: number, height: number): void;
  52946. /**
  52947. * Gets the context of the canvas used by the texture
  52948. * @returns the canvas context of the dynamic texture
  52949. */
  52950. getContext(): CanvasRenderingContext2D;
  52951. /**
  52952. * Clears the texture
  52953. */
  52954. clear(): void;
  52955. /**
  52956. * Updates the texture
  52957. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52958. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  52959. */
  52960. update(invertY?: boolean, premulAlpha?: boolean): void;
  52961. /**
  52962. * Draws text onto the texture
  52963. * @param text defines the text to be drawn
  52964. * @param x defines the placement of the text from the left
  52965. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  52966. * @param font defines the font to be used with font-style, font-size, font-name
  52967. * @param color defines the color used for the text
  52968. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  52969. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52970. * @param update defines whether texture is immediately update (default is true)
  52971. */
  52972. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  52973. /**
  52974. * Clones the texture
  52975. * @returns the clone of the texture.
  52976. */
  52977. clone(): DynamicTexture;
  52978. /**
  52979. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  52980. * @returns a serialized dynamic texture object
  52981. */
  52982. serialize(): any;
  52983. private _IsCanvasElement;
  52984. /** @hidden */
  52985. _rebuild(): void;
  52986. }
  52987. }
  52988. declare module BABYLON {
  52989. /**
  52990. * Class containing static functions to help procedurally build meshes
  52991. */
  52992. export class GroundBuilder {
  52993. /**
  52994. * Creates a ground mesh
  52995. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52996. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52998. * @param name defines the name of the mesh
  52999. * @param options defines the options used to create the mesh
  53000. * @param scene defines the hosting scene
  53001. * @returns the ground mesh
  53002. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53003. */
  53004. static CreateGround(name: string, options: {
  53005. width?: number;
  53006. height?: number;
  53007. subdivisions?: number;
  53008. subdivisionsX?: number;
  53009. subdivisionsY?: number;
  53010. updatable?: boolean;
  53011. }, scene: any): Mesh;
  53012. /**
  53013. * Creates a tiled ground mesh
  53014. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53015. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53016. * * 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
  53017. * * 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
  53018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53019. * @param name defines the name of the mesh
  53020. * @param options defines the options used to create the mesh
  53021. * @param scene defines the hosting scene
  53022. * @returns the tiled ground mesh
  53023. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53024. */
  53025. static CreateTiledGround(name: string, options: {
  53026. xmin: number;
  53027. zmin: number;
  53028. xmax: number;
  53029. zmax: number;
  53030. subdivisions?: {
  53031. w: number;
  53032. h: number;
  53033. };
  53034. precision?: {
  53035. w: number;
  53036. h: number;
  53037. };
  53038. updatable?: boolean;
  53039. }, scene?: Nullable<Scene>): Mesh;
  53040. /**
  53041. * Creates a ground mesh from a height map
  53042. * * The parameter `url` sets the URL of the height map image resource.
  53043. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53044. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53045. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53046. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53047. * * 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.
  53048. * * 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).
  53049. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53051. * @param name defines the name of the mesh
  53052. * @param url defines the url to the height map
  53053. * @param options defines the options used to create the mesh
  53054. * @param scene defines the hosting scene
  53055. * @returns the ground mesh
  53056. * @see https://doc.babylonjs.com/babylon101/height_map
  53057. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53058. */
  53059. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53060. width?: number;
  53061. height?: number;
  53062. subdivisions?: number;
  53063. minHeight?: number;
  53064. maxHeight?: number;
  53065. colorFilter?: Color3;
  53066. alphaFilter?: number;
  53067. updatable?: boolean;
  53068. onReady?: (mesh: GroundMesh) => void;
  53069. }, scene?: Nullable<Scene>): GroundMesh;
  53070. }
  53071. }
  53072. declare module BABYLON {
  53073. /**
  53074. * Class containing static functions to help procedurally build meshes
  53075. */
  53076. export class TorusBuilder {
  53077. /**
  53078. * Creates a torus mesh
  53079. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53080. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53081. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53083. * * 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
  53084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53085. * @param name defines the name of the mesh
  53086. * @param options defines the options used to create the mesh
  53087. * @param scene defines the hosting scene
  53088. * @returns the torus mesh
  53089. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53090. */
  53091. static CreateTorus(name: string, options: {
  53092. diameter?: number;
  53093. thickness?: number;
  53094. tessellation?: number;
  53095. updatable?: boolean;
  53096. sideOrientation?: number;
  53097. frontUVs?: Vector4;
  53098. backUVs?: Vector4;
  53099. }, scene: any): Mesh;
  53100. }
  53101. }
  53102. declare module BABYLON {
  53103. /**
  53104. * Class containing static functions to help procedurally build meshes
  53105. */
  53106. export class CylinderBuilder {
  53107. /**
  53108. * Creates a cylinder or a cone mesh
  53109. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53110. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53111. * * 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.
  53112. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53113. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53114. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53115. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53116. * * 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).
  53117. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53118. * * 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).
  53119. * * 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
  53120. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53121. * * 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
  53122. * * 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.
  53123. * * If `enclose` is false, a ring surface is one element.
  53124. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53125. * * 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
  53126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53127. * * 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
  53128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53129. * @param name defines the name of the mesh
  53130. * @param options defines the options used to create the mesh
  53131. * @param scene defines the hosting scene
  53132. * @returns the cylinder mesh
  53133. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53134. */
  53135. static CreateCylinder(name: string, options: {
  53136. height?: number;
  53137. diameterTop?: number;
  53138. diameterBottom?: number;
  53139. diameter?: number;
  53140. tessellation?: number;
  53141. subdivisions?: number;
  53142. arc?: number;
  53143. faceColors?: Color4[];
  53144. faceUV?: Vector4[];
  53145. updatable?: boolean;
  53146. hasRings?: boolean;
  53147. enclose?: boolean;
  53148. cap?: number;
  53149. sideOrientation?: number;
  53150. frontUVs?: Vector4;
  53151. backUVs?: Vector4;
  53152. }, scene: any): Mesh;
  53153. }
  53154. }
  53155. declare module BABYLON {
  53156. /**
  53157. * States of the webXR experience
  53158. */
  53159. export enum WebXRState {
  53160. /**
  53161. * Transitioning to being in XR mode
  53162. */
  53163. ENTERING_XR = 0,
  53164. /**
  53165. * Transitioning to non XR mode
  53166. */
  53167. EXITING_XR = 1,
  53168. /**
  53169. * In XR mode and presenting
  53170. */
  53171. IN_XR = 2,
  53172. /**
  53173. * Not entered XR mode
  53174. */
  53175. NOT_IN_XR = 3
  53176. }
  53177. /**
  53178. * The state of the XR camera's tracking
  53179. */
  53180. export enum WebXRTrackingState {
  53181. /**
  53182. * No transformation received, device is not being tracked
  53183. */
  53184. NOT_TRACKING = 0,
  53185. /**
  53186. * Tracking lost - using emulated position
  53187. */
  53188. TRACKING_LOST = 1,
  53189. /**
  53190. * Transformation tracking works normally
  53191. */
  53192. TRACKING = 2
  53193. }
  53194. /**
  53195. * Abstraction of the XR render target
  53196. */
  53197. export interface WebXRRenderTarget extends IDisposable {
  53198. /**
  53199. * xrpresent context of the canvas which can be used to display/mirror xr content
  53200. */
  53201. canvasContext: WebGLRenderingContext;
  53202. /**
  53203. * xr layer for the canvas
  53204. */
  53205. xrLayer: Nullable<XRWebGLLayer>;
  53206. /**
  53207. * Initializes the xr layer for the session
  53208. * @param xrSession xr session
  53209. * @returns a promise that will resolve once the XR Layer has been created
  53210. */
  53211. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53212. }
  53213. }
  53214. declare module BABYLON {
  53215. /**
  53216. * COnfiguration object for WebXR output canvas
  53217. */
  53218. export class WebXRManagedOutputCanvasOptions {
  53219. /**
  53220. * An optional canvas in case you wish to create it yourself and provide it here.
  53221. * If not provided, a new canvas will be created
  53222. */
  53223. canvasElement?: HTMLCanvasElement;
  53224. /**
  53225. * Options for this XR Layer output
  53226. */
  53227. canvasOptions?: XRWebGLLayerInit;
  53228. /**
  53229. * CSS styling for a newly created canvas (if not provided)
  53230. */
  53231. newCanvasCssStyle?: string;
  53232. /**
  53233. * Get the default values of the configuration object
  53234. * @param engine defines the engine to use (can be null)
  53235. * @returns default values of this configuration object
  53236. */
  53237. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53238. }
  53239. /**
  53240. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  53241. */
  53242. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  53243. private _options;
  53244. private _canvas;
  53245. private _engine;
  53246. private _originalCanvasSize;
  53247. /**
  53248. * Rendering context of the canvas which can be used to display/mirror xr content
  53249. */
  53250. canvasContext: WebGLRenderingContext;
  53251. /**
  53252. * xr layer for the canvas
  53253. */
  53254. xrLayer: Nullable<XRWebGLLayer>;
  53255. /**
  53256. * Obseervers registered here will be triggered when the xr layer was initialized
  53257. */
  53258. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  53259. /**
  53260. * Initializes the canvas to be added/removed upon entering/exiting xr
  53261. * @param _xrSessionManager The XR Session manager
  53262. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  53263. */
  53264. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  53265. /**
  53266. * Disposes of the object
  53267. */
  53268. dispose(): void;
  53269. /**
  53270. * Initializes the xr layer for the session
  53271. * @param xrSession xr session
  53272. * @returns a promise that will resolve once the XR Layer has been created
  53273. */
  53274. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53275. private _addCanvas;
  53276. private _removeCanvas;
  53277. private _setCanvasSize;
  53278. private _setManagedOutputCanvas;
  53279. }
  53280. }
  53281. declare module BABYLON {
  53282. /**
  53283. * Manages an XRSession to work with Babylon's engine
  53284. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  53285. */
  53286. export class WebXRSessionManager implements IDisposable {
  53287. /** The scene which the session should be created for */
  53288. scene: Scene;
  53289. private _referenceSpace;
  53290. private _rttProvider;
  53291. private _sessionEnded;
  53292. private _xrNavigator;
  53293. private baseLayer;
  53294. /**
  53295. * The base reference space from which the session started. good if you want to reset your
  53296. * reference space
  53297. */
  53298. baseReferenceSpace: XRReferenceSpace;
  53299. /**
  53300. * Current XR frame
  53301. */
  53302. currentFrame: Nullable<XRFrame>;
  53303. /** WebXR timestamp updated every frame */
  53304. currentTimestamp: number;
  53305. /**
  53306. * Used just in case of a failure to initialize an immersive session.
  53307. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  53308. */
  53309. defaultHeightCompensation: number;
  53310. /**
  53311. * Fires every time a new xrFrame arrives which can be used to update the camera
  53312. */
  53313. onXRFrameObservable: Observable<XRFrame>;
  53314. /**
  53315. * Fires when the reference space changed
  53316. */
  53317. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  53318. /**
  53319. * Fires when the xr session is ended either by the device or manually done
  53320. */
  53321. onXRSessionEnded: Observable<any>;
  53322. /**
  53323. * Fires when the xr session is ended either by the device or manually done
  53324. */
  53325. onXRSessionInit: Observable<XRSession>;
  53326. /**
  53327. * Underlying xr session
  53328. */
  53329. session: XRSession;
  53330. /**
  53331. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  53332. * or get the offset the player is currently at.
  53333. */
  53334. viewerReferenceSpace: XRReferenceSpace;
  53335. /**
  53336. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  53337. * @param scene The scene which the session should be created for
  53338. */
  53339. constructor(
  53340. /** The scene which the session should be created for */
  53341. scene: Scene);
  53342. /**
  53343. * The current reference space used in this session. This reference space can constantly change!
  53344. * It is mainly used to offset the camera's position.
  53345. */
  53346. get referenceSpace(): XRReferenceSpace;
  53347. /**
  53348. * Set a new reference space and triggers the observable
  53349. */
  53350. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  53351. /**
  53352. * Disposes of the session manager
  53353. */
  53354. dispose(): void;
  53355. /**
  53356. * Stops the xrSession and restores the render loop
  53357. * @returns Promise which resolves after it exits XR
  53358. */
  53359. exitXRAsync(): Promise<void>;
  53360. /**
  53361. * Gets the correct render target texture to be rendered this frame for this eye
  53362. * @param eye the eye for which to get the render target
  53363. * @returns the render target for the specified eye
  53364. */
  53365. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  53366. /**
  53367. * Creates a WebXRRenderTarget object for the XR session
  53368. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  53369. * @param options optional options to provide when creating a new render target
  53370. * @returns a WebXR render target to which the session can render
  53371. */
  53372. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  53373. /**
  53374. * Initializes the manager
  53375. * After initialization enterXR can be called to start an XR session
  53376. * @returns Promise which resolves after it is initialized
  53377. */
  53378. initializeAsync(): Promise<void>;
  53379. /**
  53380. * Initializes an xr session
  53381. * @param xrSessionMode mode to initialize
  53382. * @param xrSessionInit defines optional and required values to pass to the session builder
  53383. * @returns a promise which will resolve once the session has been initialized
  53384. */
  53385. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  53386. /**
  53387. * Checks if a session would be supported for the creation options specified
  53388. * @param sessionMode session mode to check if supported eg. immersive-vr
  53389. * @returns A Promise that resolves to true if supported and false if not
  53390. */
  53391. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53392. /**
  53393. * Resets the reference space to the one started the session
  53394. */
  53395. resetReferenceSpace(): void;
  53396. /**
  53397. * Starts rendering to the xr layer
  53398. */
  53399. runXRRenderLoop(): void;
  53400. /**
  53401. * Sets the reference space on the xr session
  53402. * @param referenceSpaceType space to set
  53403. * @returns a promise that will resolve once the reference space has been set
  53404. */
  53405. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  53406. /**
  53407. * Updates the render state of the session
  53408. * @param state state to set
  53409. * @returns a promise that resolves once the render state has been updated
  53410. */
  53411. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  53412. /**
  53413. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  53414. * @param sessionMode defines the session to test
  53415. * @returns a promise with boolean as final value
  53416. */
  53417. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53418. /**
  53419. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  53420. */
  53421. get isNative(): boolean;
  53422. private _createRenderTargetTexture;
  53423. }
  53424. }
  53425. declare module BABYLON {
  53426. /**
  53427. * WebXR Camera which holds the views for the xrSession
  53428. * @see https://doc.babylonjs.com/how_to/webxr_camera
  53429. */
  53430. export class WebXRCamera extends FreeCamera {
  53431. private _xrSessionManager;
  53432. private _firstFrame;
  53433. private _referenceQuaternion;
  53434. private _referencedPosition;
  53435. private _xrInvPositionCache;
  53436. private _xrInvQuaternionCache;
  53437. private _trackingState;
  53438. /**
  53439. * Observable raised before camera teleportation
  53440. */
  53441. onBeforeCameraTeleport: Observable<Vector3>;
  53442. /**
  53443. * Observable raised after camera teleportation
  53444. */
  53445. onAfterCameraTeleport: Observable<Vector3>;
  53446. /**
  53447. * Notifies when the camera's tracking state has changed.
  53448. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  53449. */
  53450. onTrackingStateChanged: Observable<WebXRTrackingState>;
  53451. /**
  53452. * Should position compensation execute on first frame.
  53453. * This is used when copying the position from a native (non XR) camera
  53454. */
  53455. compensateOnFirstFrame: boolean;
  53456. /**
  53457. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  53458. * @param name the name of the camera
  53459. * @param scene the scene to add the camera to
  53460. * @param _xrSessionManager a constructed xr session manager
  53461. */
  53462. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  53463. /**
  53464. * Get the current XR tracking state of the camera
  53465. */
  53466. get trackingState(): WebXRTrackingState;
  53467. private _setTrackingState;
  53468. /**
  53469. * Return the user's height, unrelated to the current ground.
  53470. * This will be the y position of this camera, when ground level is 0.
  53471. */
  53472. get realWorldHeight(): number;
  53473. /** @hidden */
  53474. _updateForDualEyeDebugging(): void;
  53475. /**
  53476. * Sets this camera's transformation based on a non-vr camera
  53477. * @param otherCamera the non-vr camera to copy the transformation from
  53478. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  53479. */
  53480. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  53481. /**
  53482. * Gets the current instance class name ("WebXRCamera").
  53483. * @returns the class name
  53484. */
  53485. getClassName(): string;
  53486. private _rotate180;
  53487. private _updateFromXRSession;
  53488. private _updateNumberOfRigCameras;
  53489. private _updateReferenceSpace;
  53490. private _updateReferenceSpaceOffset;
  53491. }
  53492. }
  53493. declare module BABYLON {
  53494. /**
  53495. * Defining the interface required for a (webxr) feature
  53496. */
  53497. export interface IWebXRFeature extends IDisposable {
  53498. /**
  53499. * Is this feature attached
  53500. */
  53501. attached: boolean;
  53502. /**
  53503. * Should auto-attach be disabled?
  53504. */
  53505. disableAutoAttach: boolean;
  53506. /**
  53507. * Attach the feature to the session
  53508. * Will usually be called by the features manager
  53509. *
  53510. * @param force should attachment be forced (even when already attached)
  53511. * @returns true if successful.
  53512. */
  53513. attach(force?: boolean): boolean;
  53514. /**
  53515. * Detach the feature from the session
  53516. * Will usually be called by the features manager
  53517. *
  53518. * @returns true if successful.
  53519. */
  53520. detach(): boolean;
  53521. /**
  53522. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53523. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53524. *
  53525. * @returns whether or not the feature is compatible in this environment
  53526. */
  53527. isCompatible(): boolean;
  53528. /**
  53529. * Was this feature disposed;
  53530. */
  53531. isDisposed: boolean;
  53532. /**
  53533. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  53534. */
  53535. xrNativeFeatureName?: string;
  53536. /**
  53537. * A list of (Babylon WebXR) features this feature depends on
  53538. */
  53539. dependsOn?: string[];
  53540. /**
  53541. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  53542. */
  53543. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  53544. }
  53545. /**
  53546. * A list of the currently available features without referencing them
  53547. */
  53548. export class WebXRFeatureName {
  53549. /**
  53550. * The name of the anchor system feature
  53551. */
  53552. static readonly ANCHOR_SYSTEM: string;
  53553. /**
  53554. * The name of the background remover feature
  53555. */
  53556. static readonly BACKGROUND_REMOVER: string;
  53557. /**
  53558. * The name of the hit test feature
  53559. */
  53560. static readonly HIT_TEST: string;
  53561. /**
  53562. * The name of the mesh detection feature
  53563. */
  53564. static readonly MESH_DETECTION: string;
  53565. /**
  53566. * physics impostors for xr controllers feature
  53567. */
  53568. static readonly PHYSICS_CONTROLLERS: string;
  53569. /**
  53570. * The name of the plane detection feature
  53571. */
  53572. static readonly PLANE_DETECTION: string;
  53573. /**
  53574. * The name of the pointer selection feature
  53575. */
  53576. static readonly POINTER_SELECTION: string;
  53577. /**
  53578. * The name of the teleportation feature
  53579. */
  53580. static readonly TELEPORTATION: string;
  53581. /**
  53582. * The name of the feature points feature.
  53583. */
  53584. static readonly FEATURE_POINTS: string;
  53585. /**
  53586. * The name of the hand tracking feature.
  53587. */
  53588. static readonly HAND_TRACKING: string;
  53589. /**
  53590. * The name of the image tracking feature
  53591. */
  53592. static readonly IMAGE_TRACKING: string;
  53593. }
  53594. /**
  53595. * Defining the constructor of a feature. Used to register the modules.
  53596. */
  53597. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  53598. /**
  53599. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  53600. * It is mainly used in AR sessions.
  53601. *
  53602. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  53603. */
  53604. export class WebXRFeaturesManager implements IDisposable {
  53605. private _xrSessionManager;
  53606. private static readonly _AvailableFeatures;
  53607. private _features;
  53608. /**
  53609. * constructs a new features manages.
  53610. *
  53611. * @param _xrSessionManager an instance of WebXRSessionManager
  53612. */
  53613. constructor(_xrSessionManager: WebXRSessionManager);
  53614. /**
  53615. * Used to register a module. After calling this function a developer can use this feature in the scene.
  53616. * Mainly used internally.
  53617. *
  53618. * @param featureName the name of the feature to register
  53619. * @param constructorFunction the function used to construct the module
  53620. * @param version the (babylon) version of the module
  53621. * @param stable is that a stable version of this module
  53622. */
  53623. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  53624. /**
  53625. * Returns a constructor of a specific feature.
  53626. *
  53627. * @param featureName the name of the feature to construct
  53628. * @param version the version of the feature to load
  53629. * @param xrSessionManager the xrSessionManager. Used to construct the module
  53630. * @param options optional options provided to the module.
  53631. * @returns a function that, when called, will return a new instance of this feature
  53632. */
  53633. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  53634. /**
  53635. * Can be used to return the list of features currently registered
  53636. *
  53637. * @returns an Array of available features
  53638. */
  53639. static GetAvailableFeatures(): string[];
  53640. /**
  53641. * Gets the versions available for a specific feature
  53642. * @param featureName the name of the feature
  53643. * @returns an array with the available versions
  53644. */
  53645. static GetAvailableVersions(featureName: string): string[];
  53646. /**
  53647. * Return the latest unstable version of this feature
  53648. * @param featureName the name of the feature to search
  53649. * @returns the version number. if not found will return -1
  53650. */
  53651. static GetLatestVersionOfFeature(featureName: string): number;
  53652. /**
  53653. * Return the latest stable version of this feature
  53654. * @param featureName the name of the feature to search
  53655. * @returns the version number. if not found will return -1
  53656. */
  53657. static GetStableVersionOfFeature(featureName: string): number;
  53658. /**
  53659. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  53660. * Can be used during a session to start a feature
  53661. * @param featureName the name of feature to attach
  53662. */
  53663. attachFeature(featureName: string): void;
  53664. /**
  53665. * Can be used inside a session or when the session ends to detach a specific feature
  53666. * @param featureName the name of the feature to detach
  53667. */
  53668. detachFeature(featureName: string): void;
  53669. /**
  53670. * Used to disable an already-enabled feature
  53671. * The feature will be disposed and will be recreated once enabled.
  53672. * @param featureName the feature to disable
  53673. * @returns true if disable was successful
  53674. */
  53675. disableFeature(featureName: string | {
  53676. Name: string;
  53677. }): boolean;
  53678. /**
  53679. * dispose this features manager
  53680. */
  53681. dispose(): void;
  53682. /**
  53683. * 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.
  53684. * 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.
  53685. *
  53686. * @param featureName the name of the feature to load or the class of the feature
  53687. * @param version optional version to load. if not provided the latest version will be enabled
  53688. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  53689. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  53690. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  53691. * @returns a new constructed feature or throws an error if feature not found.
  53692. */
  53693. enableFeature(featureName: string | {
  53694. Name: string;
  53695. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  53696. /**
  53697. * get the implementation of an enabled feature.
  53698. * @param featureName the name of the feature to load
  53699. * @returns the feature class, if found
  53700. */
  53701. getEnabledFeature(featureName: string): IWebXRFeature;
  53702. /**
  53703. * Get the list of enabled features
  53704. * @returns an array of enabled features
  53705. */
  53706. getEnabledFeatures(): string[];
  53707. /**
  53708. * This function will extend the session creation configuration object with enabled features.
  53709. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  53710. * according to the defined "required" variable, provided during enableFeature call
  53711. * @param xrSessionInit the xr Session init object to extend
  53712. *
  53713. * @returns an extended XRSessionInit object
  53714. */
  53715. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  53716. }
  53717. }
  53718. declare module BABYLON {
  53719. /**
  53720. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  53721. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  53722. */
  53723. export class WebXRExperienceHelper implements IDisposable {
  53724. private scene;
  53725. private _nonVRCamera;
  53726. private _originalSceneAutoClear;
  53727. private _supported;
  53728. /**
  53729. * Camera used to render xr content
  53730. */
  53731. camera: WebXRCamera;
  53732. /** A features manager for this xr session */
  53733. featuresManager: WebXRFeaturesManager;
  53734. /**
  53735. * Observers registered here will be triggered after the camera's initial transformation is set
  53736. * This can be used to set a different ground level or an extra rotation.
  53737. *
  53738. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  53739. * to the position set after this observable is done executing.
  53740. */
  53741. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  53742. /**
  53743. * Fires when the state of the experience helper has changed
  53744. */
  53745. onStateChangedObservable: Observable<WebXRState>;
  53746. /** Session manager used to keep track of xr session */
  53747. sessionManager: WebXRSessionManager;
  53748. /**
  53749. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  53750. */
  53751. state: WebXRState;
  53752. /**
  53753. * Creates a WebXRExperienceHelper
  53754. * @param scene The scene the helper should be created in
  53755. */
  53756. private constructor();
  53757. /**
  53758. * Creates the experience helper
  53759. * @param scene the scene to attach the experience helper to
  53760. * @returns a promise for the experience helper
  53761. */
  53762. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  53763. /**
  53764. * Disposes of the experience helper
  53765. */
  53766. dispose(): void;
  53767. /**
  53768. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  53769. * @param sessionMode options for the XR session
  53770. * @param referenceSpaceType frame of reference of the XR session
  53771. * @param renderTarget the output canvas that will be used to enter XR mode
  53772. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  53773. * @returns promise that resolves after xr mode has entered
  53774. */
  53775. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  53776. /**
  53777. * Exits XR mode and returns the scene to its original state
  53778. * @returns promise that resolves after xr mode has exited
  53779. */
  53780. exitXRAsync(): Promise<void>;
  53781. private _nonXRToXRCamera;
  53782. private _setState;
  53783. }
  53784. }
  53785. declare module BABYLON {
  53786. /**
  53787. * X-Y values for axes in WebXR
  53788. */
  53789. export interface IWebXRMotionControllerAxesValue {
  53790. /**
  53791. * The value of the x axis
  53792. */
  53793. x: number;
  53794. /**
  53795. * The value of the y-axis
  53796. */
  53797. y: number;
  53798. }
  53799. /**
  53800. * changed / previous values for the values of this component
  53801. */
  53802. export interface IWebXRMotionControllerComponentChangesValues<T> {
  53803. /**
  53804. * current (this frame) value
  53805. */
  53806. current: T;
  53807. /**
  53808. * previous (last change) value
  53809. */
  53810. previous: T;
  53811. }
  53812. /**
  53813. * Represents changes in the component between current frame and last values recorded
  53814. */
  53815. export interface IWebXRMotionControllerComponentChanges {
  53816. /**
  53817. * will be populated with previous and current values if axes changed
  53818. */
  53819. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  53820. /**
  53821. * will be populated with previous and current values if pressed changed
  53822. */
  53823. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53824. /**
  53825. * will be populated with previous and current values if touched changed
  53826. */
  53827. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53828. /**
  53829. * will be populated with previous and current values if value changed
  53830. */
  53831. value?: IWebXRMotionControllerComponentChangesValues<number>;
  53832. }
  53833. /**
  53834. * This class represents a single component (for example button or thumbstick) of a motion controller
  53835. */
  53836. export class WebXRControllerComponent implements IDisposable {
  53837. /**
  53838. * the id of this component
  53839. */
  53840. id: string;
  53841. /**
  53842. * the type of the component
  53843. */
  53844. type: MotionControllerComponentType;
  53845. private _buttonIndex;
  53846. private _axesIndices;
  53847. private _axes;
  53848. private _changes;
  53849. private _currentValue;
  53850. private _hasChanges;
  53851. private _pressed;
  53852. private _touched;
  53853. /**
  53854. * button component type
  53855. */
  53856. static BUTTON_TYPE: MotionControllerComponentType;
  53857. /**
  53858. * squeeze component type
  53859. */
  53860. static SQUEEZE_TYPE: MotionControllerComponentType;
  53861. /**
  53862. * Thumbstick component type
  53863. */
  53864. static THUMBSTICK_TYPE: MotionControllerComponentType;
  53865. /**
  53866. * Touchpad component type
  53867. */
  53868. static TOUCHPAD_TYPE: MotionControllerComponentType;
  53869. /**
  53870. * trigger component type
  53871. */
  53872. static TRIGGER_TYPE: MotionControllerComponentType;
  53873. /**
  53874. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  53875. * the axes data changes
  53876. */
  53877. onAxisValueChangedObservable: Observable<{
  53878. x: number;
  53879. y: number;
  53880. }>;
  53881. /**
  53882. * Observers registered here will be triggered when the state of a button changes
  53883. * State change is either pressed / touched / value
  53884. */
  53885. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  53886. /**
  53887. * Creates a new component for a motion controller.
  53888. * It is created by the motion controller itself
  53889. *
  53890. * @param id the id of this component
  53891. * @param type the type of the component
  53892. * @param _buttonIndex index in the buttons array of the gamepad
  53893. * @param _axesIndices indices of the values in the axes array of the gamepad
  53894. */
  53895. constructor(
  53896. /**
  53897. * the id of this component
  53898. */
  53899. id: string,
  53900. /**
  53901. * the type of the component
  53902. */
  53903. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  53904. /**
  53905. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  53906. */
  53907. get axes(): IWebXRMotionControllerAxesValue;
  53908. /**
  53909. * Get the changes. Elements will be populated only if they changed with their previous and current value
  53910. */
  53911. get changes(): IWebXRMotionControllerComponentChanges;
  53912. /**
  53913. * Return whether or not the component changed the last frame
  53914. */
  53915. get hasChanges(): boolean;
  53916. /**
  53917. * is the button currently pressed
  53918. */
  53919. get pressed(): boolean;
  53920. /**
  53921. * is the button currently touched
  53922. */
  53923. get touched(): boolean;
  53924. /**
  53925. * Get the current value of this component
  53926. */
  53927. get value(): number;
  53928. /**
  53929. * Dispose this component
  53930. */
  53931. dispose(): void;
  53932. /**
  53933. * Are there axes correlating to this component
  53934. * @return true is axes data is available
  53935. */
  53936. isAxes(): boolean;
  53937. /**
  53938. * Is this component a button (hence - pressable)
  53939. * @returns true if can be pressed
  53940. */
  53941. isButton(): boolean;
  53942. /**
  53943. * update this component using the gamepad object it is in. Called on every frame
  53944. * @param nativeController the native gamepad controller object
  53945. */
  53946. update(nativeController: IMinimalMotionControllerObject): void;
  53947. }
  53948. }
  53949. declare module BABYLON {
  53950. /**
  53951. * Type used for the success callback of ImportMesh
  53952. */
  53953. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  53954. /**
  53955. * Interface used for the result of ImportMeshAsync
  53956. */
  53957. export interface ISceneLoaderAsyncResult {
  53958. /**
  53959. * The array of loaded meshes
  53960. */
  53961. readonly meshes: AbstractMesh[];
  53962. /**
  53963. * The array of loaded particle systems
  53964. */
  53965. readonly particleSystems: IParticleSystem[];
  53966. /**
  53967. * The array of loaded skeletons
  53968. */
  53969. readonly skeletons: Skeleton[];
  53970. /**
  53971. * The array of loaded animation groups
  53972. */
  53973. readonly animationGroups: AnimationGroup[];
  53974. /**
  53975. * The array of loaded transform nodes
  53976. */
  53977. readonly transformNodes: TransformNode[];
  53978. /**
  53979. * The array of loaded geometries
  53980. */
  53981. readonly geometries: Geometry[];
  53982. /**
  53983. * The array of loaded lights
  53984. */
  53985. readonly lights: Light[];
  53986. }
  53987. /**
  53988. * Interface used to represent data loading progression
  53989. */
  53990. export interface ISceneLoaderProgressEvent {
  53991. /**
  53992. * Defines if data length to load can be evaluated
  53993. */
  53994. readonly lengthComputable: boolean;
  53995. /**
  53996. * Defines the loaded data length
  53997. */
  53998. readonly loaded: number;
  53999. /**
  54000. * Defines the data length to load
  54001. */
  54002. readonly total: number;
  54003. }
  54004. /**
  54005. * Interface used by SceneLoader plugins to define supported file extensions
  54006. */
  54007. export interface ISceneLoaderPluginExtensions {
  54008. /**
  54009. * Defines the list of supported extensions
  54010. */
  54011. [extension: string]: {
  54012. isBinary: boolean;
  54013. };
  54014. }
  54015. /**
  54016. * Interface used by SceneLoader plugin factory
  54017. */
  54018. export interface ISceneLoaderPluginFactory {
  54019. /**
  54020. * Defines the name of the factory
  54021. */
  54022. name: string;
  54023. /**
  54024. * Function called to create a new plugin
  54025. * @return the new plugin
  54026. */
  54027. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  54028. /**
  54029. * The callback that returns true if the data can be directly loaded.
  54030. * @param data string containing the file data
  54031. * @returns if the data can be loaded directly
  54032. */
  54033. canDirectLoad?(data: string): boolean;
  54034. }
  54035. /**
  54036. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  54037. */
  54038. export interface ISceneLoaderPluginBase {
  54039. /**
  54040. * The friendly name of this plugin.
  54041. */
  54042. name: string;
  54043. /**
  54044. * The file extensions supported by this plugin.
  54045. */
  54046. extensions: string | ISceneLoaderPluginExtensions;
  54047. /**
  54048. * The callback called when loading from a url.
  54049. * @param scene scene loading this url
  54050. * @param url url to load
  54051. * @param onSuccess callback called when the file successfully loads
  54052. * @param onProgress callback called while file is loading (if the server supports this mode)
  54053. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54054. * @param onError callback called when the file fails to load
  54055. * @returns a file request object
  54056. */
  54057. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54058. /**
  54059. * The callback called when loading from a file object.
  54060. * @param scene scene loading this file
  54061. * @param file defines the file to load
  54062. * @param onSuccess defines the callback to call when data is loaded
  54063. * @param onProgress defines the callback to call during loading process
  54064. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54065. * @param onError defines the callback to call when an error occurs
  54066. * @returns a file request object
  54067. */
  54068. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54069. /**
  54070. * The callback that returns true if the data can be directly loaded.
  54071. * @param data string containing the file data
  54072. * @returns if the data can be loaded directly
  54073. */
  54074. canDirectLoad?(data: string): boolean;
  54075. /**
  54076. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54077. * @param scene scene loading this data
  54078. * @param data string containing the data
  54079. * @returns data to pass to the plugin
  54080. */
  54081. directLoad?(scene: Scene, data: string): any;
  54082. /**
  54083. * The callback that allows custom handling of the root url based on the response url.
  54084. * @param rootUrl the original root url
  54085. * @param responseURL the response url if available
  54086. * @returns the new root url
  54087. */
  54088. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54089. }
  54090. /**
  54091. * Interface used to define a SceneLoader plugin
  54092. */
  54093. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54094. /**
  54095. * Import meshes into a scene.
  54096. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54097. * @param scene The scene to import into
  54098. * @param data The data to import
  54099. * @param rootUrl The root url for scene and resources
  54100. * @param meshes The meshes array to import into
  54101. * @param particleSystems The particle systems array to import into
  54102. * @param skeletons The skeletons array to import into
  54103. * @param onError The callback when import fails
  54104. * @returns True if successful or false otherwise
  54105. */
  54106. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54107. /**
  54108. * Load into a scene.
  54109. * @param scene The scene to load into
  54110. * @param data The data to import
  54111. * @param rootUrl The root url for scene and resources
  54112. * @param onError The callback when import fails
  54113. * @returns True if successful or false otherwise
  54114. */
  54115. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54116. /**
  54117. * Load into an asset container.
  54118. * @param scene The scene to load into
  54119. * @param data The data to import
  54120. * @param rootUrl The root url for scene and resources
  54121. * @param onError The callback when import fails
  54122. * @returns The loaded asset container
  54123. */
  54124. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54125. }
  54126. /**
  54127. * Interface used to define an async SceneLoader plugin
  54128. */
  54129. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54130. /**
  54131. * Import meshes into a scene.
  54132. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54133. * @param scene The scene to import into
  54134. * @param data The data to import
  54135. * @param rootUrl The root url for scene and resources
  54136. * @param onProgress The callback when the load progresses
  54137. * @param fileName Defines the name of the file to load
  54138. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54139. */
  54140. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54141. /**
  54142. * Load into a scene.
  54143. * @param scene The scene to load into
  54144. * @param data The data to import
  54145. * @param rootUrl The root url for scene and resources
  54146. * @param onProgress The callback when the load progresses
  54147. * @param fileName Defines the name of the file to load
  54148. * @returns Nothing
  54149. */
  54150. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54151. /**
  54152. * Load into an asset container.
  54153. * @param scene The scene to load into
  54154. * @param data The data to import
  54155. * @param rootUrl The root url for scene and resources
  54156. * @param onProgress The callback when the load progresses
  54157. * @param fileName Defines the name of the file to load
  54158. * @returns The loaded asset container
  54159. */
  54160. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54161. }
  54162. /**
  54163. * Mode that determines how to handle old animation groups before loading new ones.
  54164. */
  54165. export enum SceneLoaderAnimationGroupLoadingMode {
  54166. /**
  54167. * Reset all old animations to initial state then dispose them.
  54168. */
  54169. Clean = 0,
  54170. /**
  54171. * Stop all old animations.
  54172. */
  54173. Stop = 1,
  54174. /**
  54175. * Restart old animations from first frame.
  54176. */
  54177. Sync = 2,
  54178. /**
  54179. * Old animations remains untouched.
  54180. */
  54181. NoSync = 3
  54182. }
  54183. /**
  54184. * Defines a plugin registered by the SceneLoader
  54185. */
  54186. interface IRegisteredPlugin {
  54187. /**
  54188. * Defines the plugin to use
  54189. */
  54190. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54191. /**
  54192. * Defines if the plugin supports binary data
  54193. */
  54194. isBinary: boolean;
  54195. }
  54196. /**
  54197. * Class used to load scene from various file formats using registered plugins
  54198. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54199. */
  54200. export class SceneLoader {
  54201. /**
  54202. * No logging while loading
  54203. */
  54204. static readonly NO_LOGGING: number;
  54205. /**
  54206. * Minimal logging while loading
  54207. */
  54208. static readonly MINIMAL_LOGGING: number;
  54209. /**
  54210. * Summary logging while loading
  54211. */
  54212. static readonly SUMMARY_LOGGING: number;
  54213. /**
  54214. * Detailled logging while loading
  54215. */
  54216. static readonly DETAILED_LOGGING: number;
  54217. /**
  54218. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54219. */
  54220. static get ForceFullSceneLoadingForIncremental(): boolean;
  54221. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54222. /**
  54223. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54224. */
  54225. static get ShowLoadingScreen(): boolean;
  54226. static set ShowLoadingScreen(value: boolean);
  54227. /**
  54228. * Defines the current logging level (while loading the scene)
  54229. * @ignorenaming
  54230. */
  54231. static get loggingLevel(): number;
  54232. static set loggingLevel(value: number);
  54233. /**
  54234. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54235. */
  54236. static get CleanBoneMatrixWeights(): boolean;
  54237. static set CleanBoneMatrixWeights(value: boolean);
  54238. /**
  54239. * Event raised when a plugin is used to load a scene
  54240. */
  54241. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54242. private static _registeredPlugins;
  54243. private static _showingLoadingScreen;
  54244. /**
  54245. * Gets the default plugin (used to load Babylon files)
  54246. * @returns the .babylon plugin
  54247. */
  54248. static GetDefaultPlugin(): IRegisteredPlugin;
  54249. private static _GetPluginForExtension;
  54250. private static _GetPluginForDirectLoad;
  54251. private static _GetPluginForFilename;
  54252. private static _GetDirectLoad;
  54253. private static _LoadData;
  54254. private static _GetFileInfo;
  54255. /**
  54256. * Gets a plugin that can load the given extension
  54257. * @param extension defines the extension to load
  54258. * @returns a plugin or null if none works
  54259. */
  54260. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54261. /**
  54262. * Gets a boolean indicating that the given extension can be loaded
  54263. * @param extension defines the extension to load
  54264. * @returns true if the extension is supported
  54265. */
  54266. static IsPluginForExtensionAvailable(extension: string): boolean;
  54267. /**
  54268. * Adds a new plugin to the list of registered plugins
  54269. * @param plugin defines the plugin to add
  54270. */
  54271. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  54272. /**
  54273. * Import meshes into a scene
  54274. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54275. * @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)
  54276. * @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)
  54277. * @param scene the instance of BABYLON.Scene to append to
  54278. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  54279. * @param onProgress a callback with a progress event for each file being loaded
  54280. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54281. * @param pluginExtension the extension used to determine the plugin
  54282. * @returns The loaded plugin
  54283. */
  54284. 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>;
  54285. /**
  54286. * Import meshes into a scene
  54287. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54288. * @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)
  54289. * @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)
  54290. * @param scene the instance of BABYLON.Scene to append to
  54291. * @param onProgress a callback with a progress event for each file being loaded
  54292. * @param pluginExtension the extension used to determine the plugin
  54293. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  54294. */
  54295. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  54296. /**
  54297. * Load a scene
  54298. * @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)
  54299. * @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)
  54300. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54301. * @param onSuccess a callback with the scene when import succeeds
  54302. * @param onProgress a callback with a progress event for each file being loaded
  54303. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54304. * @param pluginExtension the extension used to determine the plugin
  54305. * @returns The loaded plugin
  54306. */
  54307. 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>;
  54308. /**
  54309. * Load a scene
  54310. * @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)
  54311. * @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)
  54312. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54313. * @param onProgress a callback with a progress event for each file being loaded
  54314. * @param pluginExtension the extension used to determine the plugin
  54315. * @returns The loaded scene
  54316. */
  54317. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54318. /**
  54319. * Append a scene
  54320. * @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)
  54321. * @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)
  54322. * @param scene is the instance of BABYLON.Scene to append to
  54323. * @param onSuccess a callback with the scene when import succeeds
  54324. * @param onProgress a callback with a progress event for each file being loaded
  54325. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54326. * @param pluginExtension the extension used to determine the plugin
  54327. * @returns The loaded plugin
  54328. */
  54329. 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>;
  54330. /**
  54331. * Append a scene
  54332. * @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)
  54333. * @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)
  54334. * @param scene is the instance of BABYLON.Scene to append to
  54335. * @param onProgress a callback with a progress event for each file being loaded
  54336. * @param pluginExtension the extension used to determine the plugin
  54337. * @returns The given scene
  54338. */
  54339. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54340. /**
  54341. * Load a scene into an asset container
  54342. * @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)
  54343. * @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)
  54344. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54345. * @param onSuccess a callback with the scene when import succeeds
  54346. * @param onProgress a callback with a progress event for each file being loaded
  54347. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54348. * @param pluginExtension the extension used to determine the plugin
  54349. * @returns The loaded plugin
  54350. */
  54351. 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>;
  54352. /**
  54353. * Load a scene into an asset container
  54354. * @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)
  54355. * @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)
  54356. * @param scene is the instance of Scene to append to
  54357. * @param onProgress a callback with a progress event for each file being loaded
  54358. * @param pluginExtension the extension used to determine the plugin
  54359. * @returns The loaded asset container
  54360. */
  54361. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  54362. /**
  54363. * Import animations from a file into a scene
  54364. * @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)
  54365. * @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)
  54366. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54367. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54368. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54369. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54370. * @param onSuccess a callback with the scene when import succeeds
  54371. * @param onProgress a callback with a progress event for each file being loaded
  54372. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54373. * @param pluginExtension the extension used to determine the plugin
  54374. */
  54375. 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;
  54376. /**
  54377. * Import animations from a file into a scene
  54378. * @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)
  54379. * @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)
  54380. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54381. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54382. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54383. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54384. * @param onSuccess a callback with the scene when import succeeds
  54385. * @param onProgress a callback with a progress event for each file being loaded
  54386. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54387. * @param pluginExtension the extension used to determine the plugin
  54388. * @returns the updated scene with imported animations
  54389. */
  54390. 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>;
  54391. }
  54392. }
  54393. declare module BABYLON {
  54394. /**
  54395. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  54396. */
  54397. export type MotionControllerHandedness = "none" | "left" | "right";
  54398. /**
  54399. * The type of components available in motion controllers.
  54400. * This is not the name of the component.
  54401. */
  54402. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  54403. /**
  54404. * The state of a controller component
  54405. */
  54406. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  54407. /**
  54408. * The schema of motion controller layout.
  54409. * No object will be initialized using this interface
  54410. * This is used just to define the profile.
  54411. */
  54412. export interface IMotionControllerLayout {
  54413. /**
  54414. * Path to load the assets. Usually relative to the base path
  54415. */
  54416. assetPath: string;
  54417. /**
  54418. * Available components (unsorted)
  54419. */
  54420. components: {
  54421. /**
  54422. * A map of component Ids
  54423. */
  54424. [componentId: string]: {
  54425. /**
  54426. * The type of input the component outputs
  54427. */
  54428. type: MotionControllerComponentType;
  54429. /**
  54430. * The indices of this component in the gamepad object
  54431. */
  54432. gamepadIndices: {
  54433. /**
  54434. * Index of button
  54435. */
  54436. button?: number;
  54437. /**
  54438. * If available, index of x-axis
  54439. */
  54440. xAxis?: number;
  54441. /**
  54442. * If available, index of y-axis
  54443. */
  54444. yAxis?: number;
  54445. };
  54446. /**
  54447. * The mesh's root node name
  54448. */
  54449. rootNodeName: string;
  54450. /**
  54451. * Animation definitions for this model
  54452. */
  54453. visualResponses: {
  54454. [stateKey: string]: {
  54455. /**
  54456. * What property will be animated
  54457. */
  54458. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  54459. /**
  54460. * What states influence this visual response
  54461. */
  54462. states: MotionControllerComponentStateType[];
  54463. /**
  54464. * Type of animation - movement or visibility
  54465. */
  54466. valueNodeProperty: "transform" | "visibility";
  54467. /**
  54468. * Base node name to move. Its position will be calculated according to the min and max nodes
  54469. */
  54470. valueNodeName?: string;
  54471. /**
  54472. * Minimum movement node
  54473. */
  54474. minNodeName?: string;
  54475. /**
  54476. * Max movement node
  54477. */
  54478. maxNodeName?: string;
  54479. };
  54480. };
  54481. /**
  54482. * If touch enabled, what is the name of node to display user feedback
  54483. */
  54484. touchPointNodeName?: string;
  54485. };
  54486. };
  54487. /**
  54488. * Is it xr standard mapping or not
  54489. */
  54490. gamepadMapping: "" | "xr-standard";
  54491. /**
  54492. * Base root node of this entire model
  54493. */
  54494. rootNodeName: string;
  54495. /**
  54496. * Defines the main button component id
  54497. */
  54498. selectComponentId: string;
  54499. }
  54500. /**
  54501. * A definition for the layout map in the input profile
  54502. */
  54503. export interface IMotionControllerLayoutMap {
  54504. /**
  54505. * Layouts with handedness type as a key
  54506. */
  54507. [handedness: string]: IMotionControllerLayout;
  54508. }
  54509. /**
  54510. * The XR Input profile schema
  54511. * Profiles can be found here:
  54512. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  54513. */
  54514. export interface IMotionControllerProfile {
  54515. /**
  54516. * fallback profiles for this profileId
  54517. */
  54518. fallbackProfileIds: string[];
  54519. /**
  54520. * The layout map, with handedness as key
  54521. */
  54522. layouts: IMotionControllerLayoutMap;
  54523. /**
  54524. * The id of this profile
  54525. * correlates to the profile(s) in the xrInput.profiles array
  54526. */
  54527. profileId: string;
  54528. }
  54529. /**
  54530. * A helper-interface for the 3 meshes needed for controller button animation
  54531. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  54532. */
  54533. export interface IMotionControllerButtonMeshMap {
  54534. /**
  54535. * the mesh that defines the pressed value mesh position.
  54536. * This is used to find the max-position of this button
  54537. */
  54538. pressedMesh: AbstractMesh;
  54539. /**
  54540. * the mesh that defines the unpressed value mesh position.
  54541. * This is used to find the min (or initial) position of this button
  54542. */
  54543. unpressedMesh: AbstractMesh;
  54544. /**
  54545. * The mesh that will be changed when value changes
  54546. */
  54547. valueMesh: AbstractMesh;
  54548. }
  54549. /**
  54550. * A helper-interface for the 3 meshes needed for controller axis animation.
  54551. * This will be expanded when touchpad animations are fully supported
  54552. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  54553. */
  54554. export interface IMotionControllerMeshMap {
  54555. /**
  54556. * the mesh that defines the maximum value mesh position.
  54557. */
  54558. maxMesh?: AbstractMesh;
  54559. /**
  54560. * the mesh that defines the minimum value mesh position.
  54561. */
  54562. minMesh?: AbstractMesh;
  54563. /**
  54564. * The mesh that will be changed when axis value changes
  54565. */
  54566. valueMesh?: AbstractMesh;
  54567. }
  54568. /**
  54569. * The elements needed for change-detection of the gamepad objects in motion controllers
  54570. */
  54571. export interface IMinimalMotionControllerObject {
  54572. /**
  54573. * Available axes of this controller
  54574. */
  54575. axes: number[];
  54576. /**
  54577. * An array of available buttons
  54578. */
  54579. buttons: Array<{
  54580. /**
  54581. * Value of the button/trigger
  54582. */
  54583. value: number;
  54584. /**
  54585. * If the button/trigger is currently touched
  54586. */
  54587. touched: boolean;
  54588. /**
  54589. * If the button/trigger is currently pressed
  54590. */
  54591. pressed: boolean;
  54592. }>;
  54593. /**
  54594. * EXPERIMENTAL haptic support.
  54595. */
  54596. hapticActuators?: Array<{
  54597. pulse: (value: number, duration: number) => Promise<boolean>;
  54598. }>;
  54599. }
  54600. /**
  54601. * An Abstract Motion controller
  54602. * This class receives an xrInput and a profile layout and uses those to initialize the components
  54603. * Each component has an observable to check for changes in value and state
  54604. */
  54605. export abstract class WebXRAbstractMotionController implements IDisposable {
  54606. protected scene: Scene;
  54607. protected layout: IMotionControllerLayout;
  54608. /**
  54609. * The gamepad object correlating to this controller
  54610. */
  54611. gamepadObject: IMinimalMotionControllerObject;
  54612. /**
  54613. * handedness (left/right/none) of this controller
  54614. */
  54615. handedness: MotionControllerHandedness;
  54616. private _initComponent;
  54617. private _modelReady;
  54618. /**
  54619. * A map of components (WebXRControllerComponent) in this motion controller
  54620. * Components have a ComponentType and can also have both button and axis definitions
  54621. */
  54622. readonly components: {
  54623. [id: string]: WebXRControllerComponent;
  54624. };
  54625. /**
  54626. * Disable the model's animation. Can be set at any time.
  54627. */
  54628. disableAnimation: boolean;
  54629. /**
  54630. * Observers registered here will be triggered when the model of this controller is done loading
  54631. */
  54632. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  54633. /**
  54634. * The profile id of this motion controller
  54635. */
  54636. abstract profileId: string;
  54637. /**
  54638. * The root mesh of the model. It is null if the model was not yet initialized
  54639. */
  54640. rootMesh: Nullable<AbstractMesh>;
  54641. /**
  54642. * constructs a new abstract motion controller
  54643. * @param scene the scene to which the model of the controller will be added
  54644. * @param layout The profile layout to load
  54645. * @param gamepadObject The gamepad object correlating to this controller
  54646. * @param handedness handedness (left/right/none) of this controller
  54647. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  54648. */
  54649. constructor(scene: Scene, layout: IMotionControllerLayout,
  54650. /**
  54651. * The gamepad object correlating to this controller
  54652. */
  54653. gamepadObject: IMinimalMotionControllerObject,
  54654. /**
  54655. * handedness (left/right/none) of this controller
  54656. */
  54657. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  54658. /**
  54659. * Dispose this controller, the model mesh and all its components
  54660. */
  54661. dispose(): void;
  54662. /**
  54663. * Returns all components of specific type
  54664. * @param type the type to search for
  54665. * @return an array of components with this type
  54666. */
  54667. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  54668. /**
  54669. * get a component based an its component id as defined in layout.components
  54670. * @param id the id of the component
  54671. * @returns the component correlates to the id or undefined if not found
  54672. */
  54673. getComponent(id: string): WebXRControllerComponent;
  54674. /**
  54675. * Get the list of components available in this motion controller
  54676. * @returns an array of strings correlating to available components
  54677. */
  54678. getComponentIds(): string[];
  54679. /**
  54680. * Get the first component of specific type
  54681. * @param type type of component to find
  54682. * @return a controller component or null if not found
  54683. */
  54684. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  54685. /**
  54686. * Get the main (Select) component of this controller as defined in the layout
  54687. * @returns the main component of this controller
  54688. */
  54689. getMainComponent(): WebXRControllerComponent;
  54690. /**
  54691. * Loads the model correlating to this controller
  54692. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  54693. * @returns A promise fulfilled with the result of the model loading
  54694. */
  54695. loadModel(): Promise<boolean>;
  54696. /**
  54697. * Update this model using the current XRFrame
  54698. * @param xrFrame the current xr frame to use and update the model
  54699. */
  54700. updateFromXRFrame(xrFrame: XRFrame): void;
  54701. /**
  54702. * Backwards compatibility due to a deeply-integrated typo
  54703. */
  54704. get handness(): XREye;
  54705. /**
  54706. * Pulse (vibrate) this controller
  54707. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  54708. * Consecutive calls to this function will cancel the last pulse call
  54709. *
  54710. * @param value the strength of the pulse in 0.0...1.0 range
  54711. * @param duration Duration of the pulse in milliseconds
  54712. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  54713. * @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
  54714. */
  54715. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  54716. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54717. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54718. /**
  54719. * Moves the axis on the controller mesh based on its current state
  54720. * @param axis the index of the axis
  54721. * @param axisValue the value of the axis which determines the meshes new position
  54722. * @hidden
  54723. */
  54724. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  54725. /**
  54726. * Update the model itself with the current frame data
  54727. * @param xrFrame the frame to use for updating the model mesh
  54728. */
  54729. protected updateModel(xrFrame: XRFrame): void;
  54730. /**
  54731. * Get the filename and path for this controller's model
  54732. * @returns a map of filename and path
  54733. */
  54734. protected abstract _getFilenameAndPath(): {
  54735. filename: string;
  54736. path: string;
  54737. };
  54738. /**
  54739. * This function is called before the mesh is loaded. It checks for loading constraints.
  54740. * For example, this function can check if the GLB loader is available
  54741. * If this function returns false, the generic controller will be loaded instead
  54742. * @returns Is the client ready to load the mesh
  54743. */
  54744. protected abstract _getModelLoadingConstraints(): boolean;
  54745. /**
  54746. * This function will be called after the model was successfully loaded and can be used
  54747. * for mesh transformations before it is available for the user
  54748. * @param meshes the loaded meshes
  54749. */
  54750. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  54751. /**
  54752. * Set the root mesh for this controller. Important for the WebXR controller class
  54753. * @param meshes the loaded meshes
  54754. */
  54755. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  54756. /**
  54757. * A function executed each frame that updates the mesh (if needed)
  54758. * @param xrFrame the current xrFrame
  54759. */
  54760. protected abstract _updateModel(xrFrame: XRFrame): void;
  54761. private _getGenericFilenameAndPath;
  54762. private _getGenericParentMesh;
  54763. }
  54764. }
  54765. declare module BABYLON {
  54766. /**
  54767. * A generic trigger-only motion controller for WebXR
  54768. */
  54769. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  54770. /**
  54771. * Static version of the profile id of this controller
  54772. */
  54773. static ProfileId: string;
  54774. profileId: string;
  54775. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  54776. protected _getFilenameAndPath(): {
  54777. filename: string;
  54778. path: string;
  54779. };
  54780. protected _getModelLoadingConstraints(): boolean;
  54781. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  54782. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54783. protected _updateModel(): void;
  54784. }
  54785. }
  54786. declare module BABYLON {
  54787. /**
  54788. * Class containing static functions to help procedurally build meshes
  54789. */
  54790. export class SphereBuilder {
  54791. /**
  54792. * Creates a sphere mesh
  54793. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54794. * * 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`)
  54795. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54796. * * 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
  54797. * * 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)
  54798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54799. * * 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
  54800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54801. * @param name defines the name of the mesh
  54802. * @param options defines the options used to create the mesh
  54803. * @param scene defines the hosting scene
  54804. * @returns the sphere mesh
  54805. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54806. */
  54807. static CreateSphere(name: string, options: {
  54808. segments?: number;
  54809. diameter?: number;
  54810. diameterX?: number;
  54811. diameterY?: number;
  54812. diameterZ?: number;
  54813. arc?: number;
  54814. slice?: number;
  54815. sideOrientation?: number;
  54816. frontUVs?: Vector4;
  54817. backUVs?: Vector4;
  54818. updatable?: boolean;
  54819. }, scene?: Nullable<Scene>): Mesh;
  54820. }
  54821. }
  54822. declare module BABYLON {
  54823. /**
  54824. * A profiled motion controller has its profile loaded from an online repository.
  54825. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  54826. */
  54827. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  54828. private _repositoryUrl;
  54829. private _buttonMeshMapping;
  54830. private _touchDots;
  54831. /**
  54832. * The profile ID of this controller. Will be populated when the controller initializes.
  54833. */
  54834. profileId: string;
  54835. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  54836. dispose(): void;
  54837. protected _getFilenameAndPath(): {
  54838. filename: string;
  54839. path: string;
  54840. };
  54841. protected _getModelLoadingConstraints(): boolean;
  54842. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  54843. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54844. protected _updateModel(_xrFrame: XRFrame): void;
  54845. }
  54846. }
  54847. declare module BABYLON {
  54848. /**
  54849. * A construction function type to create a new controller based on an xrInput object
  54850. */
  54851. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  54852. /**
  54853. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  54854. *
  54855. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  54856. * it should be replaced with auto-loaded controllers.
  54857. *
  54858. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  54859. */
  54860. export class WebXRMotionControllerManager {
  54861. private static _AvailableControllers;
  54862. private static _Fallbacks;
  54863. private static _ProfileLoadingPromises;
  54864. private static _ProfilesList;
  54865. /**
  54866. * The base URL of the online controller repository. Can be changed at any time.
  54867. */
  54868. static BaseRepositoryUrl: string;
  54869. /**
  54870. * Which repository gets priority - local or online
  54871. */
  54872. static PrioritizeOnlineRepository: boolean;
  54873. /**
  54874. * Use the online repository, or use only locally-defined controllers
  54875. */
  54876. static UseOnlineRepository: boolean;
  54877. /**
  54878. * Clear the cache used for profile loading and reload when requested again
  54879. */
  54880. static ClearProfilesCache(): void;
  54881. /**
  54882. * Register the default fallbacks.
  54883. * This function is called automatically when this file is imported.
  54884. */
  54885. static DefaultFallbacks(): void;
  54886. /**
  54887. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  54888. * @param profileId the profile to which a fallback needs to be found
  54889. * @return an array with corresponding fallback profiles
  54890. */
  54891. static FindFallbackWithProfileId(profileId: string): string[];
  54892. /**
  54893. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  54894. * The order of search:
  54895. *
  54896. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  54897. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  54898. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  54899. * 4) return the generic trigger controller if none were found
  54900. *
  54901. * @param xrInput the xrInput to which a new controller is initialized
  54902. * @param scene the scene to which the model will be added
  54903. * @param forceProfile force a certain profile for this controller
  54904. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  54905. */
  54906. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  54907. /**
  54908. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  54909. *
  54910. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  54911. *
  54912. * @param type the profile type to register
  54913. * @param constructFunction the function to be called when loading this profile
  54914. */
  54915. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  54916. /**
  54917. * Register a fallback to a specific profile.
  54918. * @param profileId the profileId that will receive the fallbacks
  54919. * @param fallbacks A list of fallback profiles
  54920. */
  54921. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  54922. /**
  54923. * Will update the list of profiles available in the repository
  54924. * @return a promise that resolves to a map of profiles available online
  54925. */
  54926. static UpdateProfilesList(): Promise<{
  54927. [profile: string]: string;
  54928. }>;
  54929. private static _LoadProfileFromRepository;
  54930. private static _LoadProfilesFromAvailableControllers;
  54931. }
  54932. }
  54933. declare module BABYLON {
  54934. /**
  54935. * Configuration options for the WebXR controller creation
  54936. */
  54937. export interface IWebXRControllerOptions {
  54938. /**
  54939. * Should the controller mesh be animated when a user interacts with it
  54940. * The pressed buttons / thumbstick and touchpad animations will be disabled
  54941. */
  54942. disableMotionControllerAnimation?: boolean;
  54943. /**
  54944. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  54945. */
  54946. doNotLoadControllerMesh?: boolean;
  54947. /**
  54948. * Force a specific controller type for this controller.
  54949. * This can be used when creating your own profile or when testing different controllers
  54950. */
  54951. forceControllerProfile?: string;
  54952. /**
  54953. * Defines a rendering group ID for meshes that will be loaded.
  54954. * This is for the default controllers only.
  54955. */
  54956. renderingGroupId?: number;
  54957. }
  54958. /**
  54959. * Represents an XR controller
  54960. */
  54961. export class WebXRInputSource {
  54962. private _scene;
  54963. /** The underlying input source for the controller */
  54964. inputSource: XRInputSource;
  54965. private _options;
  54966. private _tmpVector;
  54967. private _uniqueId;
  54968. private _disposed;
  54969. /**
  54970. * 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
  54971. */
  54972. grip?: AbstractMesh;
  54973. /**
  54974. * If available, this is the gamepad object related to this controller.
  54975. * Using this object it is possible to get click events and trackpad changes of the
  54976. * webxr controller that is currently being used.
  54977. */
  54978. motionController?: WebXRAbstractMotionController;
  54979. /**
  54980. * Event that fires when the controller is removed/disposed.
  54981. * The object provided as event data is this controller, after associated assets were disposed.
  54982. * uniqueId is still available.
  54983. */
  54984. onDisposeObservable: Observable<WebXRInputSource>;
  54985. /**
  54986. * Will be triggered when the mesh associated with the motion controller is done loading.
  54987. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  54988. * A shortened version of controller -> motion controller -> on mesh loaded.
  54989. */
  54990. onMeshLoadedObservable: Observable<AbstractMesh>;
  54991. /**
  54992. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  54993. */
  54994. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  54995. /**
  54996. * Pointer which can be used to select objects or attach a visible laser to
  54997. */
  54998. pointer: AbstractMesh;
  54999. /**
  55000. * Creates the input source object
  55001. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  55002. * @param _scene the scene which the controller should be associated to
  55003. * @param inputSource the underlying input source for the controller
  55004. * @param _options options for this controller creation
  55005. */
  55006. constructor(_scene: Scene,
  55007. /** The underlying input source for the controller */
  55008. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  55009. /**
  55010. * Get this controllers unique id
  55011. */
  55012. get uniqueId(): string;
  55013. /**
  55014. * Disposes of the object
  55015. */
  55016. dispose(): void;
  55017. /**
  55018. * Gets a world space ray coming from the pointer or grip
  55019. * @param result the resulting ray
  55020. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  55021. */
  55022. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  55023. /**
  55024. * Updates the controller pose based on the given XRFrame
  55025. * @param xrFrame xr frame to update the pose with
  55026. * @param referenceSpace reference space to use
  55027. */
  55028. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  55029. }
  55030. }
  55031. declare module BABYLON {
  55032. /**
  55033. * The schema for initialization options of the XR Input class
  55034. */
  55035. export interface IWebXRInputOptions {
  55036. /**
  55037. * If set to true no model will be automatically loaded
  55038. */
  55039. doNotLoadControllerMeshes?: boolean;
  55040. /**
  55041. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  55042. * If not found, the xr input profile data will be used.
  55043. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55044. */
  55045. forceInputProfile?: string;
  55046. /**
  55047. * Do not send a request to the controller repository to load the profile.
  55048. *
  55049. * Instead, use the controllers available in babylon itself.
  55050. */
  55051. disableOnlineControllerRepository?: boolean;
  55052. /**
  55053. * A custom URL for the controllers repository
  55054. */
  55055. customControllersRepositoryURL?: string;
  55056. /**
  55057. * Should the controller model's components not move according to the user input
  55058. */
  55059. disableControllerAnimation?: boolean;
  55060. /**
  55061. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55062. */
  55063. controllerOptions?: IWebXRControllerOptions;
  55064. }
  55065. /**
  55066. * XR input used to track XR inputs such as controllers/rays
  55067. */
  55068. export class WebXRInput implements IDisposable {
  55069. /**
  55070. * the xr session manager for this session
  55071. */
  55072. xrSessionManager: WebXRSessionManager;
  55073. /**
  55074. * the WebXR camera for this session. Mainly used for teleportation
  55075. */
  55076. xrCamera: WebXRCamera;
  55077. private readonly options;
  55078. /**
  55079. * XR controllers being tracked
  55080. */
  55081. controllers: Array<WebXRInputSource>;
  55082. private _frameObserver;
  55083. private _sessionEndedObserver;
  55084. private _sessionInitObserver;
  55085. /**
  55086. * Event when a controller has been connected/added
  55087. */
  55088. onControllerAddedObservable: Observable<WebXRInputSource>;
  55089. /**
  55090. * Event when a controller has been removed/disconnected
  55091. */
  55092. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55093. /**
  55094. * Initializes the WebXRInput
  55095. * @param xrSessionManager the xr session manager for this session
  55096. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55097. * @param options = initialization options for this xr input
  55098. */
  55099. constructor(
  55100. /**
  55101. * the xr session manager for this session
  55102. */
  55103. xrSessionManager: WebXRSessionManager,
  55104. /**
  55105. * the WebXR camera for this session. Mainly used for teleportation
  55106. */
  55107. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55108. private _onInputSourcesChange;
  55109. private _addAndRemoveControllers;
  55110. /**
  55111. * Disposes of the object
  55112. */
  55113. dispose(): void;
  55114. }
  55115. }
  55116. declare module BABYLON {
  55117. /**
  55118. * This is the base class for all WebXR features.
  55119. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55120. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55121. */
  55122. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55123. protected _xrSessionManager: WebXRSessionManager;
  55124. private _attached;
  55125. private _removeOnDetach;
  55126. /**
  55127. * Is this feature disposed?
  55128. */
  55129. isDisposed: boolean;
  55130. /**
  55131. * Should auto-attach be disabled?
  55132. */
  55133. disableAutoAttach: boolean;
  55134. /**
  55135. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55136. */
  55137. xrNativeFeatureName: string;
  55138. /**
  55139. * Construct a new (abstract) WebXR feature
  55140. * @param _xrSessionManager the xr session manager for this feature
  55141. */
  55142. constructor(_xrSessionManager: WebXRSessionManager);
  55143. /**
  55144. * Is this feature attached
  55145. */
  55146. get attached(): boolean;
  55147. /**
  55148. * attach this feature
  55149. *
  55150. * @param force should attachment be forced (even when already attached)
  55151. * @returns true if successful, false is failed or already attached
  55152. */
  55153. attach(force?: boolean): boolean;
  55154. /**
  55155. * detach this feature.
  55156. *
  55157. * @returns true if successful, false if failed or already detached
  55158. */
  55159. detach(): boolean;
  55160. /**
  55161. * Dispose this feature and all of the resources attached
  55162. */
  55163. dispose(): void;
  55164. /**
  55165. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55166. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55167. *
  55168. * @returns whether or not the feature is compatible in this environment
  55169. */
  55170. isCompatible(): boolean;
  55171. /**
  55172. * This is used to register callbacks that will automatically be removed when detach is called.
  55173. * @param observable the observable to which the observer will be attached
  55174. * @param callback the callback to register
  55175. */
  55176. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55177. /**
  55178. * Code in this function will be executed on each xrFrame received from the browser.
  55179. * This function will not execute after the feature is detached.
  55180. * @param _xrFrame the current frame
  55181. */
  55182. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55183. }
  55184. }
  55185. declare module BABYLON {
  55186. /**
  55187. * Renders a layer on top of an existing scene
  55188. */
  55189. export class UtilityLayerRenderer implements IDisposable {
  55190. /** the original scene that will be rendered on top of */
  55191. originalScene: Scene;
  55192. private _pointerCaptures;
  55193. private _lastPointerEvents;
  55194. private static _DefaultUtilityLayer;
  55195. private static _DefaultKeepDepthUtilityLayer;
  55196. private _sharedGizmoLight;
  55197. private _renderCamera;
  55198. /**
  55199. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55200. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55201. * @returns the camera that is used when rendering the utility layer
  55202. */
  55203. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55204. /**
  55205. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55206. * @param cam the camera that should be used when rendering the utility layer
  55207. */
  55208. setRenderCamera(cam: Nullable<Camera>): void;
  55209. /**
  55210. * @hidden
  55211. * Light which used by gizmos to get light shading
  55212. */
  55213. _getSharedGizmoLight(): HemisphericLight;
  55214. /**
  55215. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55216. */
  55217. pickUtilitySceneFirst: boolean;
  55218. /**
  55219. * 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)
  55220. */
  55221. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55222. /**
  55223. * 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)
  55224. */
  55225. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55226. /**
  55227. * The scene that is rendered on top of the original scene
  55228. */
  55229. utilityLayerScene: Scene;
  55230. /**
  55231. * If the utility layer should automatically be rendered on top of existing scene
  55232. */
  55233. shouldRender: boolean;
  55234. /**
  55235. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55236. */
  55237. onlyCheckPointerDownEvents: boolean;
  55238. /**
  55239. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  55240. */
  55241. processAllEvents: boolean;
  55242. /**
  55243. * Observable raised when the pointer move from the utility layer scene to the main scene
  55244. */
  55245. onPointerOutObservable: Observable<number>;
  55246. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  55247. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  55248. private _afterRenderObserver;
  55249. private _sceneDisposeObserver;
  55250. private _originalPointerObserver;
  55251. /**
  55252. * Instantiates a UtilityLayerRenderer
  55253. * @param originalScene the original scene that will be rendered on top of
  55254. * @param handleEvents boolean indicating if the utility layer should handle events
  55255. */
  55256. constructor(
  55257. /** the original scene that will be rendered on top of */
  55258. originalScene: Scene, handleEvents?: boolean);
  55259. private _notifyObservers;
  55260. /**
  55261. * Renders the utility layers scene on top of the original scene
  55262. */
  55263. render(): void;
  55264. /**
  55265. * Disposes of the renderer
  55266. */
  55267. dispose(): void;
  55268. private _updateCamera;
  55269. }
  55270. }
  55271. declare module BABYLON {
  55272. /**
  55273. * Options interface for the pointer selection module
  55274. */
  55275. export interface IWebXRControllerPointerSelectionOptions {
  55276. /**
  55277. * if provided, this scene will be used to render meshes.
  55278. */
  55279. customUtilityLayerScene?: Scene;
  55280. /**
  55281. * 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)
  55282. * If not disabled, the last picked point will be used to execute a pointer up event
  55283. * If disabled, pointer up event will be triggered right after the pointer down event.
  55284. * Used in screen and gaze target ray mode only
  55285. */
  55286. disablePointerUpOnTouchOut: boolean;
  55287. /**
  55288. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  55289. */
  55290. forceGazeMode: boolean;
  55291. /**
  55292. * 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
  55293. * to start a new countdown to the pointer down event.
  55294. * Defaults to 1.
  55295. */
  55296. gazeModePointerMovedFactor?: number;
  55297. /**
  55298. * Different button type to use instead of the main component
  55299. */
  55300. overrideButtonId?: string;
  55301. /**
  55302. * use this rendering group id for the meshes (optional)
  55303. */
  55304. renderingGroupId?: number;
  55305. /**
  55306. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  55307. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  55308. * 3000 means 3 seconds between pointing at something and selecting it
  55309. */
  55310. timeToSelect?: number;
  55311. /**
  55312. * Should meshes created here be added to a utility layer or the main scene
  55313. */
  55314. useUtilityLayer?: boolean;
  55315. /**
  55316. * Optional WebXR camera to be used for gaze selection
  55317. */
  55318. gazeCamera?: WebXRCamera;
  55319. /**
  55320. * the xr input to use with this pointer selection
  55321. */
  55322. xrInput: WebXRInput;
  55323. /**
  55324. * Should the scene pointerX and pointerY update be disabled
  55325. * This is required for fullscreen AR GUI, but might slow down other experiences.
  55326. * Disable in VR, if not needed.
  55327. * The first rig camera (left eye) will be used to calculate the projection
  55328. */
  55329. disableScenePointerVectorUpdate: boolean;
  55330. /**
  55331. * Enable pointer selection on all controllers instead of switching between them
  55332. */
  55333. enablePointerSelectionOnAllControllers?: boolean;
  55334. /**
  55335. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  55336. * If switch is enabled, it will still allow the user to switch between the different controllers
  55337. */
  55338. preferredHandedness?: XRHandedness;
  55339. /**
  55340. * Disable switching the pointer selection from one controller to the other.
  55341. * 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
  55342. */
  55343. disableSwitchOnClick?: boolean;
  55344. /**
  55345. * The maximum distance of the pointer selection feature. Defaults to 100.
  55346. */
  55347. maxPointerDistance?: number;
  55348. }
  55349. /**
  55350. * A module that will enable pointer selection for motion controllers of XR Input Sources
  55351. */
  55352. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  55353. private readonly _options;
  55354. private static _idCounter;
  55355. private _attachController;
  55356. private _controllers;
  55357. private _scene;
  55358. private _tmpVectorForPickCompare;
  55359. private _attachedController;
  55360. /**
  55361. * The module's name
  55362. */
  55363. static readonly Name: string;
  55364. /**
  55365. * The (Babylon) version of this module.
  55366. * This is an integer representing the implementation version.
  55367. * This number does not correspond to the WebXR specs version
  55368. */
  55369. static readonly Version: number;
  55370. /**
  55371. * Disable lighting on the laser pointer (so it will always be visible)
  55372. */
  55373. disablePointerLighting: boolean;
  55374. /**
  55375. * Disable lighting on the selection mesh (so it will always be visible)
  55376. */
  55377. disableSelectionMeshLighting: boolean;
  55378. /**
  55379. * Should the laser pointer be displayed
  55380. */
  55381. displayLaserPointer: boolean;
  55382. /**
  55383. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  55384. */
  55385. displaySelectionMesh: boolean;
  55386. /**
  55387. * This color will be set to the laser pointer when selection is triggered
  55388. */
  55389. laserPointerPickedColor: Color3;
  55390. /**
  55391. * Default color of the laser pointer
  55392. */
  55393. laserPointerDefaultColor: Color3;
  55394. /**
  55395. * default color of the selection ring
  55396. */
  55397. selectionMeshDefaultColor: Color3;
  55398. /**
  55399. * This color will be applied to the selection ring when selection is triggered
  55400. */
  55401. selectionMeshPickedColor: Color3;
  55402. /**
  55403. * Optional filter to be used for ray selection. This predicate shares behavior with
  55404. * scene.pointerMovePredicate which takes priority if it is also assigned.
  55405. */
  55406. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55407. /**
  55408. * constructs a new background remover module
  55409. * @param _xrSessionManager the session manager for this module
  55410. * @param _options read-only options to be used in this module
  55411. */
  55412. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  55413. /**
  55414. * attach this feature
  55415. * Will usually be called by the features manager
  55416. *
  55417. * @returns true if successful.
  55418. */
  55419. attach(): boolean;
  55420. /**
  55421. * detach this feature.
  55422. * Will usually be called by the features manager
  55423. *
  55424. * @returns true if successful.
  55425. */
  55426. detach(): boolean;
  55427. /**
  55428. * Will get the mesh under a specific pointer.
  55429. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  55430. * @param controllerId the controllerId to check
  55431. * @returns The mesh under pointer or null if no mesh is under the pointer
  55432. */
  55433. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  55434. /**
  55435. * Get the xr controller that correlates to the pointer id in the pointer event
  55436. *
  55437. * @param id the pointer id to search for
  55438. * @returns the controller that correlates to this id or null if not found
  55439. */
  55440. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  55441. private _identityMatrix;
  55442. private _screenCoordinatesRef;
  55443. private _viewportRef;
  55444. protected _onXRFrame(_xrFrame: XRFrame): void;
  55445. private _attachGazeMode;
  55446. private _attachScreenRayMode;
  55447. private _attachTrackedPointerRayMode;
  55448. private _convertNormalToDirectionOfRay;
  55449. private _detachController;
  55450. private _generateNewMeshPair;
  55451. private _pickingMoved;
  55452. private _updatePointerDistance;
  55453. /** @hidden */
  55454. get lasterPointerDefaultColor(): Color3;
  55455. }
  55456. }
  55457. declare module BABYLON {
  55458. /**
  55459. * Button which can be used to enter a different mode of XR
  55460. */
  55461. export class WebXREnterExitUIButton {
  55462. /** button element */
  55463. element: HTMLElement;
  55464. /** XR initialization options for the button */
  55465. sessionMode: XRSessionMode;
  55466. /** Reference space type */
  55467. referenceSpaceType: XRReferenceSpaceType;
  55468. /**
  55469. * Creates a WebXREnterExitUIButton
  55470. * @param element button element
  55471. * @param sessionMode XR initialization session mode
  55472. * @param referenceSpaceType the type of reference space to be used
  55473. */
  55474. constructor(
  55475. /** button element */
  55476. element: HTMLElement,
  55477. /** XR initialization options for the button */
  55478. sessionMode: XRSessionMode,
  55479. /** Reference space type */
  55480. referenceSpaceType: XRReferenceSpaceType);
  55481. /**
  55482. * Extendable function which can be used to update the button's visuals when the state changes
  55483. * @param activeButton the current active button in the UI
  55484. */
  55485. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  55486. }
  55487. /**
  55488. * Options to create the webXR UI
  55489. */
  55490. export class WebXREnterExitUIOptions {
  55491. /**
  55492. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  55493. */
  55494. customButtons?: Array<WebXREnterExitUIButton>;
  55495. /**
  55496. * A reference space type to use when creating the default button.
  55497. * Default is local-floor
  55498. */
  55499. referenceSpaceType?: XRReferenceSpaceType;
  55500. /**
  55501. * Context to enter xr with
  55502. */
  55503. renderTarget?: Nullable<WebXRRenderTarget>;
  55504. /**
  55505. * A session mode to use when creating the default button.
  55506. * Default is immersive-vr
  55507. */
  55508. sessionMode?: XRSessionMode;
  55509. /**
  55510. * A list of optional features to init the session with
  55511. */
  55512. optionalFeatures?: string[];
  55513. /**
  55514. * A list of optional features to init the session with
  55515. */
  55516. requiredFeatures?: string[];
  55517. /**
  55518. * If defined, this function will be executed if the UI encounters an error when entering XR
  55519. */
  55520. onError?: (error: any) => void;
  55521. }
  55522. /**
  55523. * UI to allow the user to enter/exit XR mode
  55524. */
  55525. export class WebXREnterExitUI implements IDisposable {
  55526. private scene;
  55527. /** version of the options passed to this UI */
  55528. options: WebXREnterExitUIOptions;
  55529. private _activeButton;
  55530. private _buttons;
  55531. /**
  55532. * The HTML Div Element to which buttons are added.
  55533. */
  55534. readonly overlay: HTMLDivElement;
  55535. /**
  55536. * Fired every time the active button is changed.
  55537. *
  55538. * When xr is entered via a button that launches xr that button will be the callback parameter
  55539. *
  55540. * When exiting xr the callback parameter will be null)
  55541. */
  55542. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  55543. /**
  55544. *
  55545. * @param scene babylon scene object to use
  55546. * @param options (read-only) version of the options passed to this UI
  55547. */
  55548. private constructor();
  55549. /**
  55550. * Creates UI to allow the user to enter/exit XR mode
  55551. * @param scene the scene to add the ui to
  55552. * @param helper the xr experience helper to enter/exit xr with
  55553. * @param options options to configure the UI
  55554. * @returns the created ui
  55555. */
  55556. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  55557. /**
  55558. * Disposes of the XR UI component
  55559. */
  55560. dispose(): void;
  55561. private _updateButtons;
  55562. }
  55563. }
  55564. declare module BABYLON {
  55565. /**
  55566. * Class containing static functions to help procedurally build meshes
  55567. */
  55568. export class LinesBuilder {
  55569. /**
  55570. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55571. * * 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
  55572. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55573. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55574. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55575. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55576. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55577. * * 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
  55578. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55580. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55581. * @param name defines the name of the new line system
  55582. * @param options defines the options used to create the line system
  55583. * @param scene defines the hosting scene
  55584. * @returns a new line system mesh
  55585. */
  55586. static CreateLineSystem(name: string, options: {
  55587. lines: Vector3[][];
  55588. updatable?: boolean;
  55589. instance?: Nullable<LinesMesh>;
  55590. colors?: Nullable<Color4[][]>;
  55591. useVertexAlpha?: boolean;
  55592. }, scene: Nullable<Scene>): LinesMesh;
  55593. /**
  55594. * Creates a line mesh
  55595. * 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
  55596. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55597. * * The parameter `points` is an array successive Vector3
  55598. * * 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
  55599. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55600. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55601. * * When updating an instance, remember that only point positions can change, not the number of points
  55602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55603. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55604. * @param name defines the name of the new line system
  55605. * @param options defines the options used to create the line system
  55606. * @param scene defines the hosting scene
  55607. * @returns a new line mesh
  55608. */
  55609. static CreateLines(name: string, options: {
  55610. points: Vector3[];
  55611. updatable?: boolean;
  55612. instance?: Nullable<LinesMesh>;
  55613. colors?: Color4[];
  55614. useVertexAlpha?: boolean;
  55615. }, scene?: Nullable<Scene>): LinesMesh;
  55616. /**
  55617. * Creates a dashed line mesh
  55618. * * 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
  55619. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55620. * * The parameter `points` is an array successive Vector3
  55621. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55622. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55623. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55624. * * 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
  55625. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55626. * * When updating an instance, remember that only point positions can change, not the number of points
  55627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55628. * @param name defines the name of the mesh
  55629. * @param options defines the options used to create the mesh
  55630. * @param scene defines the hosting scene
  55631. * @returns the dashed line mesh
  55632. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55633. */
  55634. static CreateDashedLines(name: string, options: {
  55635. points: Vector3[];
  55636. dashSize?: number;
  55637. gapSize?: number;
  55638. dashNb?: number;
  55639. updatable?: boolean;
  55640. instance?: LinesMesh;
  55641. useVertexAlpha?: boolean;
  55642. }, scene?: Nullable<Scene>): LinesMesh;
  55643. }
  55644. }
  55645. declare module BABYLON {
  55646. /**
  55647. * Construction options for a timer
  55648. */
  55649. export interface ITimerOptions<T> {
  55650. /**
  55651. * Time-to-end
  55652. */
  55653. timeout: number;
  55654. /**
  55655. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  55656. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  55657. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  55658. */
  55659. contextObservable: Observable<T>;
  55660. /**
  55661. * Optional parameters when adding an observer to the observable
  55662. */
  55663. observableParameters?: {
  55664. mask?: number;
  55665. insertFirst?: boolean;
  55666. scope?: any;
  55667. };
  55668. /**
  55669. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  55670. */
  55671. breakCondition?: (data?: ITimerData<T>) => boolean;
  55672. /**
  55673. * Will be triggered when the time condition has met
  55674. */
  55675. onEnded?: (data: ITimerData<any>) => void;
  55676. /**
  55677. * Will be triggered when the break condition has met (prematurely ended)
  55678. */
  55679. onAborted?: (data: ITimerData<any>) => void;
  55680. /**
  55681. * Optional function to execute on each tick (or count)
  55682. */
  55683. onTick?: (data: ITimerData<any>) => void;
  55684. }
  55685. /**
  55686. * An interface defining the data sent by the timer
  55687. */
  55688. export interface ITimerData<T> {
  55689. /**
  55690. * When did it start
  55691. */
  55692. startTime: number;
  55693. /**
  55694. * Time now
  55695. */
  55696. currentTime: number;
  55697. /**
  55698. * Time passed since started
  55699. */
  55700. deltaTime: number;
  55701. /**
  55702. * How much is completed, in [0.0...1.0].
  55703. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  55704. */
  55705. completeRate: number;
  55706. /**
  55707. * What the registered observable sent in the last count
  55708. */
  55709. payload: T;
  55710. }
  55711. /**
  55712. * The current state of the timer
  55713. */
  55714. export enum TimerState {
  55715. /**
  55716. * Timer initialized, not yet started
  55717. */
  55718. INIT = 0,
  55719. /**
  55720. * Timer started and counting
  55721. */
  55722. STARTED = 1,
  55723. /**
  55724. * Timer ended (whether aborted or time reached)
  55725. */
  55726. ENDED = 2
  55727. }
  55728. /**
  55729. * A simple version of the timer. Will take options and start the timer immediately after calling it
  55730. *
  55731. * @param options options with which to initialize this timer
  55732. */
  55733. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  55734. /**
  55735. * An advanced implementation of a timer class
  55736. */
  55737. export class AdvancedTimer<T = any> implements IDisposable {
  55738. /**
  55739. * Will notify each time the timer calculates the remaining time
  55740. */
  55741. onEachCountObservable: Observable<ITimerData<T>>;
  55742. /**
  55743. * Will trigger when the timer was aborted due to the break condition
  55744. */
  55745. onTimerAbortedObservable: Observable<ITimerData<T>>;
  55746. /**
  55747. * Will trigger when the timer ended successfully
  55748. */
  55749. onTimerEndedObservable: Observable<ITimerData<T>>;
  55750. /**
  55751. * Will trigger when the timer state has changed
  55752. */
  55753. onStateChangedObservable: Observable<TimerState>;
  55754. private _observer;
  55755. private _contextObservable;
  55756. private _observableParameters;
  55757. private _startTime;
  55758. private _timer;
  55759. private _state;
  55760. private _breakCondition;
  55761. private _timeToEnd;
  55762. private _breakOnNextTick;
  55763. /**
  55764. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  55765. * @param options construction options for this advanced timer
  55766. */
  55767. constructor(options: ITimerOptions<T>);
  55768. /**
  55769. * set a breaking condition for this timer. Default is to never break during count
  55770. * @param predicate the new break condition. Returns true to break, false otherwise
  55771. */
  55772. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  55773. /**
  55774. * Reset ALL associated observables in this advanced timer
  55775. */
  55776. clearObservables(): void;
  55777. /**
  55778. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  55779. *
  55780. * @param timeToEnd how much time to measure until timer ended
  55781. */
  55782. start(timeToEnd?: number): void;
  55783. /**
  55784. * Will force a stop on the next tick.
  55785. */
  55786. stop(): void;
  55787. /**
  55788. * Dispose this timer, clearing all resources
  55789. */
  55790. dispose(): void;
  55791. private _setState;
  55792. private _tick;
  55793. private _stop;
  55794. }
  55795. }
  55796. declare module BABYLON {
  55797. /**
  55798. * The options container for the teleportation module
  55799. */
  55800. export interface IWebXRTeleportationOptions {
  55801. /**
  55802. * if provided, this scene will be used to render meshes.
  55803. */
  55804. customUtilityLayerScene?: Scene;
  55805. /**
  55806. * Values to configure the default target mesh
  55807. */
  55808. defaultTargetMeshOptions?: {
  55809. /**
  55810. * Fill color of the teleportation area
  55811. */
  55812. teleportationFillColor?: string;
  55813. /**
  55814. * Border color for the teleportation area
  55815. */
  55816. teleportationBorderColor?: string;
  55817. /**
  55818. * Disable the mesh's animation sequence
  55819. */
  55820. disableAnimation?: boolean;
  55821. /**
  55822. * Disable lighting on the material or the ring and arrow
  55823. */
  55824. disableLighting?: boolean;
  55825. /**
  55826. * Override the default material of the torus and arrow
  55827. */
  55828. torusArrowMaterial?: Material;
  55829. };
  55830. /**
  55831. * A list of meshes to use as floor meshes.
  55832. * Meshes can be added and removed after initializing the feature using the
  55833. * addFloorMesh and removeFloorMesh functions
  55834. * If empty, rotation will still work
  55835. */
  55836. floorMeshes?: AbstractMesh[];
  55837. /**
  55838. * use this rendering group id for the meshes (optional)
  55839. */
  55840. renderingGroupId?: number;
  55841. /**
  55842. * Should teleportation move only to snap points
  55843. */
  55844. snapPointsOnly?: boolean;
  55845. /**
  55846. * An array of points to which the teleportation will snap to.
  55847. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  55848. */
  55849. snapPositions?: Vector3[];
  55850. /**
  55851. * How close should the teleportation ray be in order to snap to position.
  55852. * Default to 0.8 units (meters)
  55853. */
  55854. snapToPositionRadius?: number;
  55855. /**
  55856. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  55857. * If you want to support rotation, make sure your mesh has a direction indicator.
  55858. *
  55859. * When left untouched, the default mesh will be initialized.
  55860. */
  55861. teleportationTargetMesh?: AbstractMesh;
  55862. /**
  55863. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  55864. */
  55865. timeToTeleport?: number;
  55866. /**
  55867. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  55868. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  55869. */
  55870. useMainComponentOnly?: boolean;
  55871. /**
  55872. * Should meshes created here be added to a utility layer or the main scene
  55873. */
  55874. useUtilityLayer?: boolean;
  55875. /**
  55876. * Babylon XR Input class for controller
  55877. */
  55878. xrInput: WebXRInput;
  55879. /**
  55880. * Meshes that the teleportation ray cannot go through
  55881. */
  55882. pickBlockerMeshes?: AbstractMesh[];
  55883. /**
  55884. * Should teleport work only on a specific hand?
  55885. */
  55886. forceHandedness?: XRHandedness;
  55887. /**
  55888. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  55889. */
  55890. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  55891. }
  55892. /**
  55893. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  55894. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  55895. * the input of the attached controllers.
  55896. */
  55897. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  55898. private _options;
  55899. private _controllers;
  55900. private _currentTeleportationControllerId;
  55901. private _floorMeshes;
  55902. private _quadraticBezierCurve;
  55903. private _selectionFeature;
  55904. private _snapToPositions;
  55905. private _snappedToPoint;
  55906. private _teleportationRingMaterial?;
  55907. private _tmpRay;
  55908. private _tmpVector;
  55909. private _tmpQuaternion;
  55910. /**
  55911. * The module's name
  55912. */
  55913. static readonly Name: string;
  55914. /**
  55915. * The (Babylon) version of this module.
  55916. * This is an integer representing the implementation version.
  55917. * This number does not correspond to the webxr specs version
  55918. */
  55919. static readonly Version: number;
  55920. /**
  55921. * Is movement backwards enabled
  55922. */
  55923. backwardsMovementEnabled: boolean;
  55924. /**
  55925. * Distance to travel when moving backwards
  55926. */
  55927. backwardsTeleportationDistance: number;
  55928. /**
  55929. * The distance from the user to the inspection point in the direction of the controller
  55930. * A higher number will allow the user to move further
  55931. * defaults to 5 (meters, in xr units)
  55932. */
  55933. parabolicCheckRadius: number;
  55934. /**
  55935. * Should the module support parabolic ray on top of direct ray
  55936. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  55937. * Very helpful when moving between floors / different heights
  55938. */
  55939. parabolicRayEnabled: boolean;
  55940. /**
  55941. * The second type of ray - straight line.
  55942. * Should it be enabled or should the parabolic line be the only one.
  55943. */
  55944. straightRayEnabled: boolean;
  55945. /**
  55946. * How much rotation should be applied when rotating right and left
  55947. */
  55948. rotationAngle: number;
  55949. private _rotationEnabled;
  55950. /**
  55951. * Is rotation enabled when moving forward?
  55952. * Disabling this feature will prevent the user from deciding the direction when teleporting
  55953. */
  55954. get rotationEnabled(): boolean;
  55955. /**
  55956. * Sets wether rotation is enabled or not
  55957. * @param enabled is rotation enabled when teleportation is shown
  55958. */
  55959. set rotationEnabled(enabled: boolean);
  55960. /**
  55961. * Exposes the currently set teleportation target mesh.
  55962. */
  55963. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  55964. /**
  55965. * constructs a new anchor system
  55966. * @param _xrSessionManager an instance of WebXRSessionManager
  55967. * @param _options configuration object for this feature
  55968. */
  55969. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  55970. /**
  55971. * Get the snapPointsOnly flag
  55972. */
  55973. get snapPointsOnly(): boolean;
  55974. /**
  55975. * Sets the snapPointsOnly flag
  55976. * @param snapToPoints should teleportation be exclusively to snap points
  55977. */
  55978. set snapPointsOnly(snapToPoints: boolean);
  55979. /**
  55980. * Add a new mesh to the floor meshes array
  55981. * @param mesh the mesh to use as floor mesh
  55982. */
  55983. addFloorMesh(mesh: AbstractMesh): void;
  55984. /**
  55985. * Add a new snap-to point to fix teleportation to this position
  55986. * @param newSnapPoint The new Snap-To point
  55987. */
  55988. addSnapPoint(newSnapPoint: Vector3): void;
  55989. attach(): boolean;
  55990. detach(): boolean;
  55991. dispose(): void;
  55992. /**
  55993. * Remove a mesh from the floor meshes array
  55994. * @param mesh the mesh to remove
  55995. */
  55996. removeFloorMesh(mesh: AbstractMesh): void;
  55997. /**
  55998. * Remove a mesh from the floor meshes array using its name
  55999. * @param name the mesh name to remove
  56000. */
  56001. removeFloorMeshByName(name: string): void;
  56002. /**
  56003. * 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
  56004. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  56005. * @returns was the point found and removed or not
  56006. */
  56007. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  56008. /**
  56009. * This function sets a selection feature that will be disabled when
  56010. * the forward ray is shown and will be reattached when hidden.
  56011. * This is used to remove the selection rays when moving.
  56012. * @param selectionFeature the feature to disable when forward movement is enabled
  56013. */
  56014. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  56015. protected _onXRFrame(_xrFrame: XRFrame): void;
  56016. private _attachController;
  56017. private _createDefaultTargetMesh;
  56018. private _detachController;
  56019. private _findClosestSnapPointWithRadius;
  56020. private _setTargetMeshPosition;
  56021. private _setTargetMeshVisibility;
  56022. private _showParabolicPath;
  56023. private _teleportForward;
  56024. }
  56025. }
  56026. declare module BABYLON {
  56027. /**
  56028. * Options for the default xr helper
  56029. */
  56030. export class WebXRDefaultExperienceOptions {
  56031. /**
  56032. * Enable or disable default UI to enter XR
  56033. */
  56034. disableDefaultUI?: boolean;
  56035. /**
  56036. * Should teleportation not initialize. defaults to false.
  56037. */
  56038. disableTeleportation?: boolean;
  56039. /**
  56040. * Floor meshes that will be used for teleport
  56041. */
  56042. floorMeshes?: Array<AbstractMesh>;
  56043. /**
  56044. * If set to true, the first frame will not be used to reset position
  56045. * The first frame is mainly used when copying transformation from the old camera
  56046. * Mainly used in AR
  56047. */
  56048. ignoreNativeCameraTransformation?: boolean;
  56049. /**
  56050. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56051. */
  56052. inputOptions?: IWebXRInputOptions;
  56053. /**
  56054. * optional configuration for the output canvas
  56055. */
  56056. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56057. /**
  56058. * optional UI options. This can be used among other to change session mode and reference space type
  56059. */
  56060. uiOptions?: WebXREnterExitUIOptions;
  56061. /**
  56062. * When loading teleportation and pointer select, use stable versions instead of latest.
  56063. */
  56064. useStablePlugins?: boolean;
  56065. /**
  56066. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56067. */
  56068. renderingGroupId?: number;
  56069. /**
  56070. * A list of optional features to init the session with
  56071. * If set to true, all features we support will be added
  56072. */
  56073. optionalFeatures?: boolean | string[];
  56074. }
  56075. /**
  56076. * Default experience which provides a similar setup to the previous webVRExperience
  56077. */
  56078. export class WebXRDefaultExperience {
  56079. /**
  56080. * Base experience
  56081. */
  56082. baseExperience: WebXRExperienceHelper;
  56083. /**
  56084. * Enables ui for entering/exiting xr
  56085. */
  56086. enterExitUI: WebXREnterExitUI;
  56087. /**
  56088. * Input experience extension
  56089. */
  56090. input: WebXRInput;
  56091. /**
  56092. * Enables laser pointer and selection
  56093. */
  56094. pointerSelection: WebXRControllerPointerSelection;
  56095. /**
  56096. * Default target xr should render to
  56097. */
  56098. renderTarget: WebXRRenderTarget;
  56099. /**
  56100. * Enables teleportation
  56101. */
  56102. teleportation: WebXRMotionControllerTeleportation;
  56103. private constructor();
  56104. /**
  56105. * Creates the default xr experience
  56106. * @param scene scene
  56107. * @param options options for basic configuration
  56108. * @returns resulting WebXRDefaultExperience
  56109. */
  56110. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56111. /**
  56112. * DIsposes of the experience helper
  56113. */
  56114. dispose(): void;
  56115. }
  56116. }
  56117. declare module BABYLON {
  56118. /**
  56119. * Options to modify the vr teleportation behavior.
  56120. */
  56121. export interface VRTeleportationOptions {
  56122. /**
  56123. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56124. */
  56125. floorMeshName?: string;
  56126. /**
  56127. * A list of meshes to be used as the teleportation floor. (default: empty)
  56128. */
  56129. floorMeshes?: Mesh[];
  56130. /**
  56131. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56132. */
  56133. teleportationMode?: number;
  56134. /**
  56135. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56136. */
  56137. teleportationTime?: number;
  56138. /**
  56139. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56140. */
  56141. teleportationSpeed?: number;
  56142. /**
  56143. * The easing function used in the animation or null for Linear. (default CircleEase)
  56144. */
  56145. easingFunction?: EasingFunction;
  56146. }
  56147. /**
  56148. * Options to modify the vr experience helper's behavior.
  56149. */
  56150. export interface VRExperienceHelperOptions extends WebVROptions {
  56151. /**
  56152. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56153. */
  56154. createDeviceOrientationCamera?: boolean;
  56155. /**
  56156. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56157. */
  56158. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56159. /**
  56160. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56161. */
  56162. laserToggle?: boolean;
  56163. /**
  56164. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56165. */
  56166. floorMeshes?: Mesh[];
  56167. /**
  56168. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56169. */
  56170. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56171. /**
  56172. * Defines if WebXR should be used instead of WebVR (if available)
  56173. */
  56174. useXR?: boolean;
  56175. }
  56176. /**
  56177. * Event containing information after VR has been entered
  56178. */
  56179. export class OnAfterEnteringVRObservableEvent {
  56180. /**
  56181. * If entering vr was successful
  56182. */
  56183. success: boolean;
  56184. }
  56185. /**
  56186. * Helps to quickly add VR support to an existing scene.
  56187. * See https://doc.babylonjs.com/how_to/webvr_helper
  56188. */
  56189. export class VRExperienceHelper {
  56190. /** Options to modify the vr experience helper's behavior. */
  56191. webVROptions: VRExperienceHelperOptions;
  56192. private _scene;
  56193. private _position;
  56194. private _btnVR;
  56195. private _btnVRDisplayed;
  56196. private _webVRsupported;
  56197. private _webVRready;
  56198. private _webVRrequesting;
  56199. private _webVRpresenting;
  56200. private _hasEnteredVR;
  56201. private _fullscreenVRpresenting;
  56202. private _inputElement;
  56203. private _webVRCamera;
  56204. private _vrDeviceOrientationCamera;
  56205. private _deviceOrientationCamera;
  56206. private _existingCamera;
  56207. private _onKeyDown;
  56208. private _onVrDisplayPresentChange;
  56209. private _onVRDisplayChanged;
  56210. private _onVRRequestPresentStart;
  56211. private _onVRRequestPresentComplete;
  56212. /**
  56213. * 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)
  56214. */
  56215. enableGazeEvenWhenNoPointerLock: boolean;
  56216. /**
  56217. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56218. */
  56219. exitVROnDoubleTap: boolean;
  56220. /**
  56221. * Observable raised right before entering VR.
  56222. */
  56223. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56224. /**
  56225. * Observable raised when entering VR has completed.
  56226. */
  56227. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56228. /**
  56229. * Observable raised when exiting VR.
  56230. */
  56231. onExitingVRObservable: Observable<VRExperienceHelper>;
  56232. /**
  56233. * Observable raised when controller mesh is loaded.
  56234. */
  56235. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56236. /** Return this.onEnteringVRObservable
  56237. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56238. */
  56239. get onEnteringVR(): Observable<VRExperienceHelper>;
  56240. /** Return this.onExitingVRObservable
  56241. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  56242. */
  56243. get onExitingVR(): Observable<VRExperienceHelper>;
  56244. /** Return this.onControllerMeshLoadedObservable
  56245. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  56246. */
  56247. get onControllerMeshLoaded(): Observable<WebVRController>;
  56248. private _rayLength;
  56249. private _useCustomVRButton;
  56250. private _teleportationRequested;
  56251. private _teleportActive;
  56252. private _floorMeshName;
  56253. private _floorMeshesCollection;
  56254. private _teleportationMode;
  56255. private _teleportationTime;
  56256. private _teleportationSpeed;
  56257. private _teleportationEasing;
  56258. private _rotationAllowed;
  56259. private _teleportBackwardsVector;
  56260. private _teleportationTarget;
  56261. private _isDefaultTeleportationTarget;
  56262. private _postProcessMove;
  56263. private _teleportationFillColor;
  56264. private _teleportationBorderColor;
  56265. private _rotationAngle;
  56266. private _haloCenter;
  56267. private _cameraGazer;
  56268. private _padSensibilityUp;
  56269. private _padSensibilityDown;
  56270. private _leftController;
  56271. private _rightController;
  56272. private _gazeColor;
  56273. private _laserColor;
  56274. private _pickedLaserColor;
  56275. private _pickedGazeColor;
  56276. /**
  56277. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  56278. */
  56279. onNewMeshSelected: Observable<AbstractMesh>;
  56280. /**
  56281. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  56282. * This observable will provide the mesh and the controller used to select the mesh
  56283. */
  56284. onMeshSelectedWithController: Observable<{
  56285. mesh: AbstractMesh;
  56286. controller: WebVRController;
  56287. }>;
  56288. /**
  56289. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  56290. */
  56291. onNewMeshPicked: Observable<PickingInfo>;
  56292. private _circleEase;
  56293. /**
  56294. * Observable raised before camera teleportation
  56295. */
  56296. onBeforeCameraTeleport: Observable<Vector3>;
  56297. /**
  56298. * Observable raised after camera teleportation
  56299. */
  56300. onAfterCameraTeleport: Observable<Vector3>;
  56301. /**
  56302. * Observable raised when current selected mesh gets unselected
  56303. */
  56304. onSelectedMeshUnselected: Observable<AbstractMesh>;
  56305. private _raySelectionPredicate;
  56306. /**
  56307. * To be optionaly changed by user to define custom ray selection
  56308. */
  56309. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56310. /**
  56311. * To be optionaly changed by user to define custom selection logic (after ray selection)
  56312. */
  56313. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56314. /**
  56315. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  56316. */
  56317. teleportationEnabled: boolean;
  56318. private _defaultHeight;
  56319. private _teleportationInitialized;
  56320. private _interactionsEnabled;
  56321. private _interactionsRequested;
  56322. private _displayGaze;
  56323. private _displayLaserPointer;
  56324. /**
  56325. * The mesh used to display where the user is going to teleport.
  56326. */
  56327. get teleportationTarget(): Mesh;
  56328. /**
  56329. * Sets the mesh to be used to display where the user is going to teleport.
  56330. */
  56331. set teleportationTarget(value: Mesh);
  56332. /**
  56333. * 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
  56334. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  56335. * See https://doc.babylonjs.com/resources/baking_transformations
  56336. */
  56337. get gazeTrackerMesh(): Mesh;
  56338. set gazeTrackerMesh(value: Mesh);
  56339. /**
  56340. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  56341. */
  56342. updateGazeTrackerScale: boolean;
  56343. /**
  56344. * If the gaze trackers color should be updated when selecting meshes
  56345. */
  56346. updateGazeTrackerColor: boolean;
  56347. /**
  56348. * If the controller laser color should be updated when selecting meshes
  56349. */
  56350. updateControllerLaserColor: boolean;
  56351. /**
  56352. * The gaze tracking mesh corresponding to the left controller
  56353. */
  56354. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  56355. /**
  56356. * The gaze tracking mesh corresponding to the right controller
  56357. */
  56358. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  56359. /**
  56360. * If the ray of the gaze should be displayed.
  56361. */
  56362. get displayGaze(): boolean;
  56363. /**
  56364. * Sets if the ray of the gaze should be displayed.
  56365. */
  56366. set displayGaze(value: boolean);
  56367. /**
  56368. * If the ray of the LaserPointer should be displayed.
  56369. */
  56370. get displayLaserPointer(): boolean;
  56371. /**
  56372. * Sets if the ray of the LaserPointer should be displayed.
  56373. */
  56374. set displayLaserPointer(value: boolean);
  56375. /**
  56376. * The deviceOrientationCamera used as the camera when not in VR.
  56377. */
  56378. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  56379. /**
  56380. * Based on the current WebVR support, returns the current VR camera used.
  56381. */
  56382. get currentVRCamera(): Nullable<Camera>;
  56383. /**
  56384. * The webVRCamera which is used when in VR.
  56385. */
  56386. get webVRCamera(): WebVRFreeCamera;
  56387. /**
  56388. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  56389. */
  56390. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  56391. /**
  56392. * The html button that is used to trigger entering into VR.
  56393. */
  56394. get vrButton(): Nullable<HTMLButtonElement>;
  56395. private get _teleportationRequestInitiated();
  56396. /**
  56397. * Defines whether or not Pointer lock should be requested when switching to
  56398. * full screen.
  56399. */
  56400. requestPointerLockOnFullScreen: boolean;
  56401. /**
  56402. * If asking to force XR, this will be populated with the default xr experience
  56403. */
  56404. xr: WebXRDefaultExperience;
  56405. /**
  56406. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  56407. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  56408. */
  56409. xrTestDone: boolean;
  56410. /**
  56411. * Instantiates a VRExperienceHelper.
  56412. * Helps to quickly add VR support to an existing scene.
  56413. * @param scene The scene the VRExperienceHelper belongs to.
  56414. * @param webVROptions Options to modify the vr experience helper's behavior.
  56415. */
  56416. constructor(scene: Scene,
  56417. /** Options to modify the vr experience helper's behavior. */
  56418. webVROptions?: VRExperienceHelperOptions);
  56419. private completeVRInit;
  56420. private _onDefaultMeshLoaded;
  56421. private _onResize;
  56422. private _onFullscreenChange;
  56423. /**
  56424. * Gets a value indicating if we are currently in VR mode.
  56425. */
  56426. get isInVRMode(): boolean;
  56427. private onVrDisplayPresentChange;
  56428. private onVRDisplayChanged;
  56429. private moveButtonToBottomRight;
  56430. private displayVRButton;
  56431. private updateButtonVisibility;
  56432. private _cachedAngularSensibility;
  56433. /**
  56434. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  56435. * Otherwise, will use the fullscreen API.
  56436. */
  56437. enterVR(): void;
  56438. /**
  56439. * Attempt to exit VR, or fullscreen.
  56440. */
  56441. exitVR(): void;
  56442. /**
  56443. * The position of the vr experience helper.
  56444. */
  56445. get position(): Vector3;
  56446. /**
  56447. * Sets the position of the vr experience helper.
  56448. */
  56449. set position(value: Vector3);
  56450. /**
  56451. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  56452. */
  56453. enableInteractions(): void;
  56454. private get _noControllerIsActive();
  56455. private beforeRender;
  56456. private _isTeleportationFloor;
  56457. /**
  56458. * Adds a floor mesh to be used for teleportation.
  56459. * @param floorMesh the mesh to be used for teleportation.
  56460. */
  56461. addFloorMesh(floorMesh: Mesh): void;
  56462. /**
  56463. * Removes a floor mesh from being used for teleportation.
  56464. * @param floorMesh the mesh to be removed.
  56465. */
  56466. removeFloorMesh(floorMesh: Mesh): void;
  56467. /**
  56468. * Enables interactions and teleportation using the VR controllers and gaze.
  56469. * @param vrTeleportationOptions options to modify teleportation behavior.
  56470. */
  56471. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  56472. private _onNewGamepadConnected;
  56473. private _tryEnableInteractionOnController;
  56474. private _onNewGamepadDisconnected;
  56475. private _enableInteractionOnController;
  56476. private _checkTeleportWithRay;
  56477. private _checkRotate;
  56478. private _checkTeleportBackwards;
  56479. private _enableTeleportationOnController;
  56480. private _createTeleportationCircles;
  56481. private _displayTeleportationTarget;
  56482. private _hideTeleportationTarget;
  56483. private _rotateCamera;
  56484. private _moveTeleportationSelectorTo;
  56485. private _workingVector;
  56486. private _workingQuaternion;
  56487. private _workingMatrix;
  56488. /**
  56489. * Time Constant Teleportation Mode
  56490. */
  56491. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  56492. /**
  56493. * Speed Constant Teleportation Mode
  56494. */
  56495. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  56496. /**
  56497. * Teleports the users feet to the desired location
  56498. * @param location The location where the user's feet should be placed
  56499. */
  56500. teleportCamera(location: Vector3): void;
  56501. private _convertNormalToDirectionOfRay;
  56502. private _castRayAndSelectObject;
  56503. private _notifySelectedMeshUnselected;
  56504. /**
  56505. * Permanently set new colors for the laser pointer
  56506. * @param color the new laser color
  56507. * @param pickedColor the new laser color when picked mesh detected
  56508. */
  56509. setLaserColor(color: Color3, pickedColor?: Color3): void;
  56510. /**
  56511. * Set lighting enabled / disabled on the laser pointer of both controllers
  56512. * @param enabled should the lighting be enabled on the laser pointer
  56513. */
  56514. setLaserLightingState(enabled?: boolean): void;
  56515. /**
  56516. * Permanently set new colors for the gaze pointer
  56517. * @param color the new gaze color
  56518. * @param pickedColor the new gaze color when picked mesh detected
  56519. */
  56520. setGazeColor(color: Color3, pickedColor?: Color3): void;
  56521. /**
  56522. * Sets the color of the laser ray from the vr controllers.
  56523. * @param color new color for the ray.
  56524. */
  56525. changeLaserColor(color: Color3): void;
  56526. /**
  56527. * Sets the color of the ray from the vr headsets gaze.
  56528. * @param color new color for the ray.
  56529. */
  56530. changeGazeColor(color: Color3): void;
  56531. /**
  56532. * Exits VR and disposes of the vr experience helper
  56533. */
  56534. dispose(): void;
  56535. /**
  56536. * Gets the name of the VRExperienceHelper class
  56537. * @returns "VRExperienceHelper"
  56538. */
  56539. getClassName(): string;
  56540. }
  56541. }
  56542. declare module BABYLON {
  56543. /**
  56544. * Contains an array of blocks representing the octree
  56545. */
  56546. export interface IOctreeContainer<T> {
  56547. /**
  56548. * Blocks within the octree
  56549. */
  56550. blocks: Array<OctreeBlock<T>>;
  56551. }
  56552. /**
  56553. * Class used to store a cell in an octree
  56554. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56555. */
  56556. export class OctreeBlock<T> {
  56557. /**
  56558. * Gets the content of the current block
  56559. */
  56560. entries: T[];
  56561. /**
  56562. * Gets the list of block children
  56563. */
  56564. blocks: Array<OctreeBlock<T>>;
  56565. private _depth;
  56566. private _maxDepth;
  56567. private _capacity;
  56568. private _minPoint;
  56569. private _maxPoint;
  56570. private _boundingVectors;
  56571. private _creationFunc;
  56572. /**
  56573. * Creates a new block
  56574. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  56575. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  56576. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56577. * @param depth defines the current depth of this block in the octree
  56578. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  56579. * @param creationFunc defines a callback to call when an element is added to the block
  56580. */
  56581. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  56582. /**
  56583. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56584. */
  56585. get capacity(): number;
  56586. /**
  56587. * Gets the minimum vector (in world space) of the block's bounding box
  56588. */
  56589. get minPoint(): Vector3;
  56590. /**
  56591. * Gets the maximum vector (in world space) of the block's bounding box
  56592. */
  56593. get maxPoint(): Vector3;
  56594. /**
  56595. * Add a new element to this block
  56596. * @param entry defines the element to add
  56597. */
  56598. addEntry(entry: T): void;
  56599. /**
  56600. * Remove an element from this block
  56601. * @param entry defines the element to remove
  56602. */
  56603. removeEntry(entry: T): void;
  56604. /**
  56605. * Add an array of elements to this block
  56606. * @param entries defines the array of elements to add
  56607. */
  56608. addEntries(entries: T[]): void;
  56609. /**
  56610. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  56611. * @param frustumPlanes defines the frustum planes to test
  56612. * @param selection defines the array to store current content if selection is positive
  56613. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56614. */
  56615. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56616. /**
  56617. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  56618. * @param sphereCenter defines the bounding sphere center
  56619. * @param sphereRadius defines the bounding sphere radius
  56620. * @param selection defines the array to store current content if selection is positive
  56621. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56622. */
  56623. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56624. /**
  56625. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  56626. * @param ray defines the ray to test with
  56627. * @param selection defines the array to store current content if selection is positive
  56628. */
  56629. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  56630. /**
  56631. * Subdivide the content into child blocks (this block will then be empty)
  56632. */
  56633. createInnerBlocks(): void;
  56634. /**
  56635. * @hidden
  56636. */
  56637. 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;
  56638. }
  56639. }
  56640. declare module BABYLON {
  56641. /**
  56642. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56643. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56644. */
  56645. export class Octree<T> {
  56646. /** 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.) */
  56647. maxDepth: number;
  56648. /**
  56649. * Blocks within the octree containing objects
  56650. */
  56651. blocks: Array<OctreeBlock<T>>;
  56652. /**
  56653. * Content stored in the octree
  56654. */
  56655. dynamicContent: T[];
  56656. private _maxBlockCapacity;
  56657. private _selectionContent;
  56658. private _creationFunc;
  56659. /**
  56660. * Creates a octree
  56661. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56662. * @param creationFunc function to be used to instatiate the octree
  56663. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56664. * @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.)
  56665. */
  56666. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56667. /** 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.) */
  56668. maxDepth?: number);
  56669. /**
  56670. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56671. * @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);
  56672. * @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);
  56673. * @param entries meshes to be added to the octree blocks
  56674. */
  56675. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56676. /**
  56677. * Adds a mesh to the octree
  56678. * @param entry Mesh to add to the octree
  56679. */
  56680. addMesh(entry: T): void;
  56681. /**
  56682. * Remove an element from the octree
  56683. * @param entry defines the element to remove
  56684. */
  56685. removeMesh(entry: T): void;
  56686. /**
  56687. * Selects an array of meshes within the frustum
  56688. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56689. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56690. * @returns array of meshes within the frustum
  56691. */
  56692. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56693. /**
  56694. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56695. * @param sphereCenter defines the bounding sphere center
  56696. * @param sphereRadius defines the bounding sphere radius
  56697. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56698. * @returns an array of objects that intersect the sphere
  56699. */
  56700. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56701. /**
  56702. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56703. * @param ray defines the ray to test with
  56704. * @returns array of intersected objects
  56705. */
  56706. intersectsRay(ray: Ray): SmartArray<T>;
  56707. /**
  56708. * Adds a mesh into the octree block if it intersects the block
  56709. */
  56710. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  56711. /**
  56712. * Adds a submesh into the octree block if it intersects the block
  56713. */
  56714. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  56715. }
  56716. }
  56717. declare module BABYLON {
  56718. interface Scene {
  56719. /**
  56720. * @hidden
  56721. * Backing Filed
  56722. */
  56723. _selectionOctree: Octree<AbstractMesh>;
  56724. /**
  56725. * Gets the octree used to boost mesh selection (picking)
  56726. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56727. */
  56728. selectionOctree: Octree<AbstractMesh>;
  56729. /**
  56730. * Creates or updates the octree used to boost selection (picking)
  56731. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56732. * @param maxCapacity defines the maximum capacity per leaf
  56733. * @param maxDepth defines the maximum depth of the octree
  56734. * @returns an octree of AbstractMesh
  56735. */
  56736. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  56737. }
  56738. interface AbstractMesh {
  56739. /**
  56740. * @hidden
  56741. * Backing Field
  56742. */
  56743. _submeshesOctree: Octree<SubMesh>;
  56744. /**
  56745. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  56746. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  56747. * @param maxCapacity defines the maximum size of each block (64 by default)
  56748. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  56749. * @returns the new octree
  56750. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  56751. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56752. */
  56753. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  56754. }
  56755. /**
  56756. * Defines the octree scene component responsible to manage any octrees
  56757. * in a given scene.
  56758. */
  56759. export class OctreeSceneComponent {
  56760. /**
  56761. * The component name help to identify the component in the list of scene components.
  56762. */
  56763. readonly name: string;
  56764. /**
  56765. * The scene the component belongs to.
  56766. */
  56767. scene: Scene;
  56768. /**
  56769. * Indicates if the meshes have been checked to make sure they are isEnabled()
  56770. */
  56771. readonly checksIsEnabled: boolean;
  56772. /**
  56773. * Creates a new instance of the component for the given scene
  56774. * @param scene Defines the scene to register the component in
  56775. */
  56776. constructor(scene: Scene);
  56777. /**
  56778. * Registers the component in a given scene
  56779. */
  56780. register(): void;
  56781. /**
  56782. * Return the list of active meshes
  56783. * @returns the list of active meshes
  56784. */
  56785. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  56786. /**
  56787. * Return the list of active sub meshes
  56788. * @param mesh The mesh to get the candidates sub meshes from
  56789. * @returns the list of active sub meshes
  56790. */
  56791. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  56792. private _tempRay;
  56793. /**
  56794. * Return the list of sub meshes intersecting with a given local ray
  56795. * @param mesh defines the mesh to find the submesh for
  56796. * @param localRay defines the ray in local space
  56797. * @returns the list of intersecting sub meshes
  56798. */
  56799. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  56800. /**
  56801. * Return the list of sub meshes colliding with a collider
  56802. * @param mesh defines the mesh to find the submesh for
  56803. * @param collider defines the collider to evaluate the collision against
  56804. * @returns the list of colliding sub meshes
  56805. */
  56806. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  56807. /**
  56808. * Rebuilds the elements related to this component in case of
  56809. * context lost for instance.
  56810. */
  56811. rebuild(): void;
  56812. /**
  56813. * Disposes the component and the associated ressources.
  56814. */
  56815. dispose(): void;
  56816. }
  56817. }
  56818. declare module BABYLON {
  56819. /**
  56820. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  56821. */
  56822. export interface GizmoAxisCache {
  56823. /** Mesh used to runder the Gizmo */
  56824. gizmoMeshes: Mesh[];
  56825. /** Mesh used to detect user interaction with Gizmo */
  56826. colliderMeshes: Mesh[];
  56827. /** Material used to inicate color of gizmo mesh */
  56828. material: StandardMaterial;
  56829. /** Material used to inicate hover state of the Gizmo */
  56830. hoverMaterial: StandardMaterial;
  56831. /** Material used to inicate disabled state of the Gizmo */
  56832. disableMaterial: StandardMaterial;
  56833. /** Used to indicate Active state of the Gizmo */
  56834. active: boolean;
  56835. }
  56836. /**
  56837. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  56838. */
  56839. export class Gizmo implements IDisposable {
  56840. /** The utility layer the gizmo will be added to */
  56841. gizmoLayer: UtilityLayerRenderer;
  56842. /**
  56843. * The root mesh of the gizmo
  56844. */
  56845. _rootMesh: Mesh;
  56846. private _attachedMesh;
  56847. private _attachedNode;
  56848. /**
  56849. * Ratio for the scale of the gizmo (Default: 1)
  56850. */
  56851. protected _scaleRatio: number;
  56852. /**
  56853. * boolean updated by pointermove when a gizmo mesh is hovered
  56854. */
  56855. protected _isHovered: boolean;
  56856. /**
  56857. * Ratio for the scale of the gizmo (Default: 1)
  56858. */
  56859. set scaleRatio(value: number);
  56860. get scaleRatio(): number;
  56861. /**
  56862. * True when the mouse pointer is hovered a gizmo mesh
  56863. */
  56864. get isHovered(): boolean;
  56865. /**
  56866. * If a custom mesh has been set (Default: false)
  56867. */
  56868. protected _customMeshSet: boolean;
  56869. /**
  56870. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  56871. * * When set, interactions will be enabled
  56872. */
  56873. get attachedMesh(): Nullable<AbstractMesh>;
  56874. set attachedMesh(value: Nullable<AbstractMesh>);
  56875. /**
  56876. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  56877. * * When set, interactions will be enabled
  56878. */
  56879. get attachedNode(): Nullable<Node>;
  56880. set attachedNode(value: Nullable<Node>);
  56881. /**
  56882. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56883. * @param mesh The mesh to replace the default mesh of the gizmo
  56884. */
  56885. setCustomMesh(mesh: Mesh): void;
  56886. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  56887. /**
  56888. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  56889. */
  56890. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56891. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56892. /**
  56893. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  56894. */
  56895. updateGizmoPositionToMatchAttachedMesh: boolean;
  56896. /**
  56897. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  56898. */
  56899. updateScale: boolean;
  56900. protected _interactionsEnabled: boolean;
  56901. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56902. private _beforeRenderObserver;
  56903. private _tempQuaternion;
  56904. private _tempVector;
  56905. private _tempVector2;
  56906. private _tempMatrix1;
  56907. private _tempMatrix2;
  56908. private _rightHandtoLeftHandMatrix;
  56909. /**
  56910. * Creates a gizmo
  56911. * @param gizmoLayer The utility layer the gizmo will be added to
  56912. */
  56913. constructor(
  56914. /** The utility layer the gizmo will be added to */
  56915. gizmoLayer?: UtilityLayerRenderer);
  56916. /**
  56917. * Updates the gizmo to match the attached mesh's position/rotation
  56918. */
  56919. protected _update(): void;
  56920. /**
  56921. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  56922. * @param value Node, TransformNode or mesh
  56923. */
  56924. protected _matrixChanged(): void;
  56925. /**
  56926. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  56927. * @param gizmoLayer The utility layer the gizmo will be added to
  56928. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  56929. * @returns {Observer<PointerInfo>} pointerObserver
  56930. */
  56931. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  56932. /**
  56933. * Disposes of the gizmo
  56934. */
  56935. dispose(): void;
  56936. }
  56937. }
  56938. declare module BABYLON {
  56939. /**
  56940. * Single plane drag gizmo
  56941. */
  56942. export class PlaneDragGizmo extends Gizmo {
  56943. /**
  56944. * Drag behavior responsible for the gizmos dragging interactions
  56945. */
  56946. dragBehavior: PointerDragBehavior;
  56947. private _pointerObserver;
  56948. /**
  56949. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56950. */
  56951. snapDistance: number;
  56952. /**
  56953. * Event that fires each time the gizmo snaps to a new location.
  56954. * * snapDistance is the the change in distance
  56955. */
  56956. onSnapObservable: Observable<{
  56957. snapDistance: number;
  56958. }>;
  56959. private _gizmoMesh;
  56960. private _coloredMaterial;
  56961. private _hoverMaterial;
  56962. private _disableMaterial;
  56963. private _isEnabled;
  56964. private _parent;
  56965. private _dragging;
  56966. /** @hidden */
  56967. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  56968. /**
  56969. * Creates a PlaneDragGizmo
  56970. * @param gizmoLayer The utility layer the gizmo will be added to
  56971. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  56972. * @param color The color of the gizmo
  56973. */
  56974. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  56975. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56976. /**
  56977. * If the gizmo is enabled
  56978. */
  56979. set isEnabled(value: boolean);
  56980. get isEnabled(): boolean;
  56981. /**
  56982. * Disposes of the gizmo
  56983. */
  56984. dispose(): void;
  56985. }
  56986. }
  56987. declare module BABYLON {
  56988. /**
  56989. * Single plane rotation gizmo
  56990. */
  56991. export class PlaneRotationGizmo extends Gizmo {
  56992. /**
  56993. * Drag behavior responsible for the gizmos dragging interactions
  56994. */
  56995. dragBehavior: PointerDragBehavior;
  56996. private _pointerObserver;
  56997. /**
  56998. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56999. */
  57000. snapDistance: number;
  57001. /**
  57002. * Event that fires each time the gizmo snaps to a new location.
  57003. * * snapDistance is the the change in distance
  57004. */
  57005. onSnapObservable: Observable<{
  57006. snapDistance: number;
  57007. }>;
  57008. private _isEnabled;
  57009. private _parent;
  57010. private _coloredMaterial;
  57011. private _hoverMaterial;
  57012. private _disableMaterial;
  57013. private _gizmoMesh;
  57014. private _rotationCircle;
  57015. private _dragging;
  57016. private static _CircleConstants;
  57017. /**
  57018. * Creates a PlaneRotationGizmo
  57019. * @param gizmoLayer The utility layer the gizmo will be added to
  57020. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57021. * @param color The color of the gizmo
  57022. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57023. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57024. * @param thickness display gizmo axis thickness
  57025. */
  57026. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57027. /** Create Geometry for Gizmo */
  57028. private _createGizmoMesh;
  57029. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57030. private setupRotationCircle;
  57031. private updateRotationPath;
  57032. private updateRotationCircle;
  57033. /**
  57034. * If the gizmo is enabled
  57035. */
  57036. set isEnabled(value: boolean);
  57037. get isEnabled(): boolean;
  57038. /**
  57039. * Disposes of the gizmo
  57040. */
  57041. dispose(): void;
  57042. }
  57043. }
  57044. declare module BABYLON {
  57045. /**
  57046. * Gizmo that enables rotating a mesh along 3 axis
  57047. */
  57048. export class RotationGizmo extends Gizmo {
  57049. /**
  57050. * Internal gizmo used for interactions on the x axis
  57051. */
  57052. xGizmo: PlaneRotationGizmo;
  57053. /**
  57054. * Internal gizmo used for interactions on the y axis
  57055. */
  57056. yGizmo: PlaneRotationGizmo;
  57057. /**
  57058. * Internal gizmo used for interactions on the z axis
  57059. */
  57060. zGizmo: PlaneRotationGizmo;
  57061. /** Fires an event when any of it's sub gizmos are dragged */
  57062. onDragStartObservable: Observable<unknown>;
  57063. /** Fires an event when any of it's sub gizmos are released from dragging */
  57064. onDragEndObservable: Observable<unknown>;
  57065. private _meshAttached;
  57066. private _nodeAttached;
  57067. private _observables;
  57068. /** Node Caching for quick lookup */
  57069. private _gizmoAxisCache;
  57070. get attachedMesh(): Nullable<AbstractMesh>;
  57071. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57072. get attachedNode(): Nullable<Node>;
  57073. set attachedNode(node: Nullable<Node>);
  57074. protected _checkBillboardTransform(): void;
  57075. /**
  57076. * True when the mouse pointer is hovering a gizmo mesh
  57077. */
  57078. get isHovered(): boolean;
  57079. /**
  57080. * Creates a RotationGizmo
  57081. * @param gizmoLayer The utility layer the gizmo will be added to
  57082. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57083. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57084. * @param thickness display gizmo axis thickness
  57085. */
  57086. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57087. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57088. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57089. /**
  57090. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57091. */
  57092. set snapDistance(value: number);
  57093. get snapDistance(): number;
  57094. /**
  57095. * Ratio for the scale of the gizmo (Default: 1)
  57096. */
  57097. set scaleRatio(value: number);
  57098. get scaleRatio(): number;
  57099. /**
  57100. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57101. * @param mesh Axis gizmo mesh
  57102. * @param cache Gizmo axis definition used for reactive gizmo UI
  57103. */
  57104. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57105. /**
  57106. * Disposes of the gizmo
  57107. */
  57108. dispose(): void;
  57109. /**
  57110. * CustomMeshes are not supported by this gizmo
  57111. * @param mesh The mesh to replace the default mesh of the gizmo
  57112. */
  57113. setCustomMesh(mesh: Mesh): void;
  57114. }
  57115. }
  57116. declare module BABYLON {
  57117. /**
  57118. * Class containing static functions to help procedurally build meshes
  57119. */
  57120. export class PolyhedronBuilder {
  57121. /**
  57122. * Creates a polyhedron mesh
  57123. * * 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
  57124. * * The parameter `size` (positive float, default 1) sets the polygon size
  57125. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57126. * * 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`
  57127. * * 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
  57128. * * 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)`)
  57129. * * 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
  57130. * * 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
  57131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57132. * * 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
  57133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57134. * @param name defines the name of the mesh
  57135. * @param options defines the options used to create the mesh
  57136. * @param scene defines the hosting scene
  57137. * @returns the polyhedron mesh
  57138. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57139. */
  57140. static CreatePolyhedron(name: string, options: {
  57141. type?: number;
  57142. size?: number;
  57143. sizeX?: number;
  57144. sizeY?: number;
  57145. sizeZ?: number;
  57146. custom?: any;
  57147. faceUV?: Vector4[];
  57148. faceColors?: Color4[];
  57149. flat?: boolean;
  57150. updatable?: boolean;
  57151. sideOrientation?: number;
  57152. frontUVs?: Vector4;
  57153. backUVs?: Vector4;
  57154. }, scene?: Nullable<Scene>): Mesh;
  57155. }
  57156. }
  57157. declare module BABYLON {
  57158. /**
  57159. * Class containing static functions to help procedurally build meshes
  57160. */
  57161. export class BoxBuilder {
  57162. /**
  57163. * Creates a box mesh
  57164. * * The parameter `size` sets the size (float) of each box side (default 1)
  57165. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57166. * * 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)
  57167. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57169. * * 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
  57170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57171. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57172. * @param name defines the name of the mesh
  57173. * @param options defines the options used to create the mesh
  57174. * @param scene defines the hosting scene
  57175. * @returns the box mesh
  57176. */
  57177. static CreateBox(name: string, options: {
  57178. size?: number;
  57179. width?: number;
  57180. height?: number;
  57181. depth?: number;
  57182. faceUV?: Vector4[];
  57183. faceColors?: Color4[];
  57184. sideOrientation?: number;
  57185. frontUVs?: Vector4;
  57186. backUVs?: Vector4;
  57187. wrap?: boolean;
  57188. topBaseAt?: number;
  57189. bottomBaseAt?: number;
  57190. updatable?: boolean;
  57191. }, scene?: Nullable<Scene>): Mesh;
  57192. }
  57193. }
  57194. declare module BABYLON {
  57195. /**
  57196. * Single axis scale gizmo
  57197. */
  57198. export class AxisScaleGizmo extends Gizmo {
  57199. /**
  57200. * Drag behavior responsible for the gizmos dragging interactions
  57201. */
  57202. dragBehavior: PointerDragBehavior;
  57203. private _pointerObserver;
  57204. /**
  57205. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57206. */
  57207. snapDistance: number;
  57208. /**
  57209. * Event that fires each time the gizmo snaps to a new location.
  57210. * * snapDistance is the the change in distance
  57211. */
  57212. onSnapObservable: Observable<{
  57213. snapDistance: number;
  57214. }>;
  57215. /**
  57216. * If the scaling operation should be done on all axis (default: false)
  57217. */
  57218. uniformScaling: boolean;
  57219. /**
  57220. * Custom sensitivity value for the drag strength
  57221. */
  57222. sensitivity: number;
  57223. private _isEnabled;
  57224. private _parent;
  57225. private _gizmoMesh;
  57226. private _coloredMaterial;
  57227. private _hoverMaterial;
  57228. private _disableMaterial;
  57229. private _dragging;
  57230. private _tmpVector;
  57231. private _tmpMatrix;
  57232. private _tmpMatrix2;
  57233. /**
  57234. * Creates an AxisScaleGizmo
  57235. * @param gizmoLayer The utility layer the gizmo will be added to
  57236. * @param dragAxis The axis which the gizmo will be able to scale on
  57237. * @param color The color of the gizmo
  57238. * @param thickness display gizmo axis thickness
  57239. */
  57240. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57241. /** Create Geometry for Gizmo */
  57242. private _createGizmoMesh;
  57243. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57244. /**
  57245. * If the gizmo is enabled
  57246. */
  57247. set isEnabled(value: boolean);
  57248. get isEnabled(): boolean;
  57249. /**
  57250. * Disposes of the gizmo
  57251. */
  57252. dispose(): void;
  57253. /**
  57254. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57255. * @param mesh The mesh to replace the default mesh of the gizmo
  57256. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57257. */
  57258. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57259. }
  57260. }
  57261. declare module BABYLON {
  57262. /**
  57263. * Gizmo that enables scaling a mesh along 3 axis
  57264. */
  57265. export class ScaleGizmo extends Gizmo {
  57266. /**
  57267. * Internal gizmo used for interactions on the x axis
  57268. */
  57269. xGizmo: AxisScaleGizmo;
  57270. /**
  57271. * Internal gizmo used for interactions on the y axis
  57272. */
  57273. yGizmo: AxisScaleGizmo;
  57274. /**
  57275. * Internal gizmo used for interactions on the z axis
  57276. */
  57277. zGizmo: AxisScaleGizmo;
  57278. /**
  57279. * Internal gizmo used to scale all axis equally
  57280. */
  57281. uniformScaleGizmo: AxisScaleGizmo;
  57282. private _meshAttached;
  57283. private _nodeAttached;
  57284. private _snapDistance;
  57285. private _uniformScalingMesh;
  57286. private _octahedron;
  57287. private _sensitivity;
  57288. private _coloredMaterial;
  57289. private _hoverMaterial;
  57290. private _disableMaterial;
  57291. private _observables;
  57292. /** Node Caching for quick lookup */
  57293. private _gizmoAxisCache;
  57294. /** Fires an event when any of it's sub gizmos are dragged */
  57295. onDragStartObservable: Observable<unknown>;
  57296. /** Fires an event when any of it's sub gizmos are released from dragging */
  57297. onDragEndObservable: Observable<unknown>;
  57298. get attachedMesh(): Nullable<AbstractMesh>;
  57299. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57300. get attachedNode(): Nullable<Node>;
  57301. set attachedNode(node: Nullable<Node>);
  57302. /**
  57303. * True when the mouse pointer is hovering a gizmo mesh
  57304. */
  57305. get isHovered(): boolean;
  57306. /**
  57307. * Creates a ScaleGizmo
  57308. * @param gizmoLayer The utility layer the gizmo will be added to
  57309. * @param thickness display gizmo axis thickness
  57310. */
  57311. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57312. /** Create Geometry for Gizmo */
  57313. private _createUniformScaleMesh;
  57314. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57315. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57316. /**
  57317. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57318. */
  57319. set snapDistance(value: number);
  57320. get snapDistance(): number;
  57321. /**
  57322. * Ratio for the scale of the gizmo (Default: 1)
  57323. */
  57324. set scaleRatio(value: number);
  57325. get scaleRatio(): number;
  57326. /**
  57327. * Sensitivity factor for dragging (Default: 1)
  57328. */
  57329. set sensitivity(value: number);
  57330. get sensitivity(): number;
  57331. /**
  57332. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57333. * @param mesh Axis gizmo mesh
  57334. * @param cache Gizmo axis definition used for reactive gizmo UI
  57335. */
  57336. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57337. /**
  57338. * Disposes of the gizmo
  57339. */
  57340. dispose(): void;
  57341. }
  57342. }
  57343. declare module BABYLON {
  57344. /**
  57345. * Bounding box gizmo
  57346. */
  57347. export class BoundingBoxGizmo extends Gizmo {
  57348. private _lineBoundingBox;
  57349. private _rotateSpheresParent;
  57350. private _scaleBoxesParent;
  57351. private _boundingDimensions;
  57352. private _renderObserver;
  57353. private _pointerObserver;
  57354. private _scaleDragSpeed;
  57355. private _tmpQuaternion;
  57356. private _tmpVector;
  57357. private _tmpRotationMatrix;
  57358. /**
  57359. * 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)
  57360. */
  57361. ignoreChildren: boolean;
  57362. /**
  57363. * 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)
  57364. */
  57365. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57366. /**
  57367. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57368. */
  57369. rotationSphereSize: number;
  57370. /**
  57371. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57372. */
  57373. scaleBoxSize: number;
  57374. /**
  57375. * 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)
  57376. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57377. */
  57378. fixedDragMeshScreenSize: boolean;
  57379. /**
  57380. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  57381. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57382. */
  57383. fixedDragMeshBoundsSize: boolean;
  57384. /**
  57385. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57386. */
  57387. fixedDragMeshScreenSizeDistanceFactor: number;
  57388. /**
  57389. * Fired when a rotation sphere or scale box is dragged
  57390. */
  57391. onDragStartObservable: Observable<{}>;
  57392. /**
  57393. * Fired when a scale box is dragged
  57394. */
  57395. onScaleBoxDragObservable: Observable<{}>;
  57396. /**
  57397. * Fired when a scale box drag is ended
  57398. */
  57399. onScaleBoxDragEndObservable: Observable<{}>;
  57400. /**
  57401. * Fired when a rotation sphere is dragged
  57402. */
  57403. onRotationSphereDragObservable: Observable<{}>;
  57404. /**
  57405. * Fired when a rotation sphere drag is ended
  57406. */
  57407. onRotationSphereDragEndObservable: Observable<{}>;
  57408. /**
  57409. * 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)
  57410. */
  57411. scalePivot: Nullable<Vector3>;
  57412. /**
  57413. * Mesh used as a pivot to rotate the attached node
  57414. */
  57415. private _anchorMesh;
  57416. private _existingMeshScale;
  57417. private _dragMesh;
  57418. private pointerDragBehavior;
  57419. private coloredMaterial;
  57420. private hoverColoredMaterial;
  57421. /**
  57422. * Sets the color of the bounding box gizmo
  57423. * @param color the color to set
  57424. */
  57425. setColor(color: Color3): void;
  57426. /**
  57427. * Creates an BoundingBoxGizmo
  57428. * @param gizmoLayer The utility layer the gizmo will be added to
  57429. * @param color The color of the gizmo
  57430. */
  57431. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57432. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57433. private _selectNode;
  57434. /**
  57435. * Updates the bounding box information for the Gizmo
  57436. */
  57437. updateBoundingBox(): void;
  57438. private _updateRotationSpheres;
  57439. private _updateScaleBoxes;
  57440. /**
  57441. * Enables rotation on the specified axis and disables rotation on the others
  57442. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57443. */
  57444. setEnabledRotationAxis(axis: string): void;
  57445. /**
  57446. * Enables/disables scaling
  57447. * @param enable if scaling should be enabled
  57448. * @param homogeneousScaling defines if scaling should only be homogeneous
  57449. */
  57450. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57451. private _updateDummy;
  57452. /**
  57453. * Enables a pointer drag behavior on the bounding box of the gizmo
  57454. */
  57455. enableDragBehavior(): void;
  57456. /**
  57457. * Disposes of the gizmo
  57458. */
  57459. dispose(): void;
  57460. /**
  57461. * 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)
  57462. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57463. * @returns the bounding box mesh with the passed in mesh as a child
  57464. */
  57465. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57466. /**
  57467. * CustomMeshes are not supported by this gizmo
  57468. * @param mesh The mesh to replace the default mesh of the gizmo
  57469. */
  57470. setCustomMesh(mesh: Mesh): void;
  57471. }
  57472. }
  57473. declare module BABYLON {
  57474. /**
  57475. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57476. */
  57477. export class GizmoManager implements IDisposable {
  57478. private scene;
  57479. /**
  57480. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57481. */
  57482. gizmos: {
  57483. positionGizmo: Nullable<PositionGizmo>;
  57484. rotationGizmo: Nullable<RotationGizmo>;
  57485. scaleGizmo: Nullable<ScaleGizmo>;
  57486. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57487. };
  57488. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57489. clearGizmoOnEmptyPointerEvent: boolean;
  57490. /** Fires an event when the manager is attached to a mesh */
  57491. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57492. /** Fires an event when the manager is attached to a node */
  57493. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57494. private _gizmosEnabled;
  57495. private _pointerObservers;
  57496. private _attachedMesh;
  57497. private _attachedNode;
  57498. private _boundingBoxColor;
  57499. private _defaultUtilityLayer;
  57500. private _defaultKeepDepthUtilityLayer;
  57501. private _thickness;
  57502. /** Node Caching for quick lookup */
  57503. private _gizmoAxisCache;
  57504. /**
  57505. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57506. */
  57507. boundingBoxDragBehavior: SixDofDragBehavior;
  57508. /**
  57509. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57510. */
  57511. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57512. /**
  57513. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57514. */
  57515. attachableNodes: Nullable<Array<Node>>;
  57516. /**
  57517. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57518. */
  57519. usePointerToAttachGizmos: boolean;
  57520. /**
  57521. * Utility layer that the bounding box gizmo belongs to
  57522. */
  57523. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57524. /**
  57525. * Utility layer that all gizmos besides bounding box belong to
  57526. */
  57527. get utilityLayer(): UtilityLayerRenderer;
  57528. /**
  57529. * True when the mouse pointer is hovering a gizmo mesh
  57530. */
  57531. get isHovered(): boolean;
  57532. /**
  57533. * Instatiates a gizmo manager
  57534. * @param scene the scene to overlay the gizmos on top of
  57535. * @param thickness display gizmo axis thickness
  57536. * @param utilityLayer the layer where gizmos are rendered
  57537. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57538. */
  57539. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57540. /**
  57541. * Subscribes to pointer down events, for attaching and detaching mesh
  57542. * @param scene The sceme layer the observer will be added to
  57543. */
  57544. private _attachToMeshPointerObserver;
  57545. /**
  57546. * Attaches a set of gizmos to the specified mesh
  57547. * @param mesh The mesh the gizmo's should be attached to
  57548. */
  57549. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57550. /**
  57551. * Attaches a set of gizmos to the specified node
  57552. * @param node The node the gizmo's should be attached to
  57553. */
  57554. attachToNode(node: Nullable<Node>): void;
  57555. /**
  57556. * If the position gizmo is enabled
  57557. */
  57558. set positionGizmoEnabled(value: boolean);
  57559. get positionGizmoEnabled(): boolean;
  57560. /**
  57561. * If the rotation gizmo is enabled
  57562. */
  57563. set rotationGizmoEnabled(value: boolean);
  57564. get rotationGizmoEnabled(): boolean;
  57565. /**
  57566. * If the scale gizmo is enabled
  57567. */
  57568. set scaleGizmoEnabled(value: boolean);
  57569. get scaleGizmoEnabled(): boolean;
  57570. /**
  57571. * If the boundingBox gizmo is enabled
  57572. */
  57573. set boundingBoxGizmoEnabled(value: boolean);
  57574. get boundingBoxGizmoEnabled(): boolean;
  57575. /**
  57576. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57577. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57578. */
  57579. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57580. /**
  57581. * Disposes of the gizmo manager
  57582. */
  57583. dispose(): void;
  57584. }
  57585. }
  57586. declare module BABYLON {
  57587. /**
  57588. * Gizmo that enables dragging a mesh along 3 axis
  57589. */
  57590. export class PositionGizmo extends Gizmo {
  57591. /**
  57592. * Internal gizmo used for interactions on the x axis
  57593. */
  57594. xGizmo: AxisDragGizmo;
  57595. /**
  57596. * Internal gizmo used for interactions on the y axis
  57597. */
  57598. yGizmo: AxisDragGizmo;
  57599. /**
  57600. * Internal gizmo used for interactions on the z axis
  57601. */
  57602. zGizmo: AxisDragGizmo;
  57603. /**
  57604. * Internal gizmo used for interactions on the yz plane
  57605. */
  57606. xPlaneGizmo: PlaneDragGizmo;
  57607. /**
  57608. * Internal gizmo used for interactions on the xz plane
  57609. */
  57610. yPlaneGizmo: PlaneDragGizmo;
  57611. /**
  57612. * Internal gizmo used for interactions on the xy plane
  57613. */
  57614. zPlaneGizmo: PlaneDragGizmo;
  57615. /**
  57616. * private variables
  57617. */
  57618. private _meshAttached;
  57619. private _nodeAttached;
  57620. private _snapDistance;
  57621. private _observables;
  57622. /** Node Caching for quick lookup */
  57623. private _gizmoAxisCache;
  57624. /** Fires an event when any of it's sub gizmos are dragged */
  57625. onDragStartObservable: Observable<unknown>;
  57626. /** Fires an event when any of it's sub gizmos are released from dragging */
  57627. onDragEndObservable: Observable<unknown>;
  57628. /**
  57629. * If set to true, planar drag is enabled
  57630. */
  57631. private _planarGizmoEnabled;
  57632. get attachedMesh(): Nullable<AbstractMesh>;
  57633. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57634. get attachedNode(): Nullable<Node>;
  57635. set attachedNode(node: Nullable<Node>);
  57636. /**
  57637. * True when the mouse pointer is hovering a gizmo mesh
  57638. */
  57639. get isHovered(): boolean;
  57640. /**
  57641. * Creates a PositionGizmo
  57642. * @param gizmoLayer The utility layer the gizmo will be added to
  57643. @param thickness display gizmo axis thickness
  57644. */
  57645. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57646. /**
  57647. * If the planar drag gizmo is enabled
  57648. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57649. */
  57650. set planarGizmoEnabled(value: boolean);
  57651. get planarGizmoEnabled(): boolean;
  57652. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57653. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57654. /**
  57655. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57656. */
  57657. set snapDistance(value: number);
  57658. get snapDistance(): number;
  57659. /**
  57660. * Ratio for the scale of the gizmo (Default: 1)
  57661. */
  57662. set scaleRatio(value: number);
  57663. get scaleRatio(): number;
  57664. /**
  57665. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57666. * @param mesh Axis gizmo mesh
  57667. * @param cache Gizmo axis definition used for reactive gizmo UI
  57668. */
  57669. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57670. /**
  57671. * Disposes of the gizmo
  57672. */
  57673. dispose(): void;
  57674. /**
  57675. * CustomMeshes are not supported by this gizmo
  57676. * @param mesh The mesh to replace the default mesh of the gizmo
  57677. */
  57678. setCustomMesh(mesh: Mesh): void;
  57679. }
  57680. }
  57681. declare module BABYLON {
  57682. /**
  57683. * Single axis drag gizmo
  57684. */
  57685. export class AxisDragGizmo extends Gizmo {
  57686. /**
  57687. * Drag behavior responsible for the gizmos dragging interactions
  57688. */
  57689. dragBehavior: PointerDragBehavior;
  57690. private _pointerObserver;
  57691. /**
  57692. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57693. */
  57694. snapDistance: number;
  57695. /**
  57696. * Event that fires each time the gizmo snaps to a new location.
  57697. * * snapDistance is the the change in distance
  57698. */
  57699. onSnapObservable: Observable<{
  57700. snapDistance: number;
  57701. }>;
  57702. private _isEnabled;
  57703. private _parent;
  57704. private _gizmoMesh;
  57705. private _coloredMaterial;
  57706. private _hoverMaterial;
  57707. private _disableMaterial;
  57708. private _dragging;
  57709. /** @hidden */
  57710. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  57711. /** @hidden */
  57712. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  57713. /**
  57714. * Creates an AxisDragGizmo
  57715. * @param gizmoLayer The utility layer the gizmo will be added to
  57716. * @param dragAxis The axis which the gizmo will be able to drag on
  57717. * @param color The color of the gizmo
  57718. * @param thickness display gizmo axis thickness
  57719. */
  57720. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  57721. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57722. /**
  57723. * If the gizmo is enabled
  57724. */
  57725. set isEnabled(value: boolean);
  57726. get isEnabled(): boolean;
  57727. /**
  57728. * Disposes of the gizmo
  57729. */
  57730. dispose(): void;
  57731. }
  57732. }
  57733. declare module BABYLON.Debug {
  57734. /**
  57735. * The Axes viewer will show 3 axes in a specific point in space
  57736. */
  57737. export class AxesViewer {
  57738. private _xAxis;
  57739. private _yAxis;
  57740. private _zAxis;
  57741. private _scaleLinesFactor;
  57742. private _instanced;
  57743. /**
  57744. * Gets the hosting scene
  57745. */
  57746. scene: Nullable<Scene>;
  57747. /**
  57748. * Gets or sets a number used to scale line length
  57749. */
  57750. scaleLines: number;
  57751. /** Gets the node hierarchy used to render x-axis */
  57752. get xAxis(): TransformNode;
  57753. /** Gets the node hierarchy used to render y-axis */
  57754. get yAxis(): TransformNode;
  57755. /** Gets the node hierarchy used to render z-axis */
  57756. get zAxis(): TransformNode;
  57757. /**
  57758. * Creates a new AxesViewer
  57759. * @param scene defines the hosting scene
  57760. * @param scaleLines defines a number used to scale line length (1 by default)
  57761. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  57762. * @param xAxis defines the node hierarchy used to render the x-axis
  57763. * @param yAxis defines the node hierarchy used to render the y-axis
  57764. * @param zAxis defines the node hierarchy used to render the z-axis
  57765. */
  57766. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  57767. /**
  57768. * Force the viewer to update
  57769. * @param position defines the position of the viewer
  57770. * @param xaxis defines the x axis of the viewer
  57771. * @param yaxis defines the y axis of the viewer
  57772. * @param zaxis defines the z axis of the viewer
  57773. */
  57774. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  57775. /**
  57776. * Creates an instance of this axes viewer.
  57777. * @returns a new axes viewer with instanced meshes
  57778. */
  57779. createInstance(): AxesViewer;
  57780. /** Releases resources */
  57781. dispose(): void;
  57782. private static _SetRenderingGroupId;
  57783. }
  57784. }
  57785. declare module BABYLON.Debug {
  57786. /**
  57787. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  57788. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  57789. */
  57790. export class BoneAxesViewer extends AxesViewer {
  57791. /**
  57792. * Gets or sets the target mesh where to display the axes viewer
  57793. */
  57794. mesh: Nullable<Mesh>;
  57795. /**
  57796. * Gets or sets the target bone where to display the axes viewer
  57797. */
  57798. bone: Nullable<Bone>;
  57799. /** Gets current position */
  57800. pos: Vector3;
  57801. /** Gets direction of X axis */
  57802. xaxis: Vector3;
  57803. /** Gets direction of Y axis */
  57804. yaxis: Vector3;
  57805. /** Gets direction of Z axis */
  57806. zaxis: Vector3;
  57807. /**
  57808. * Creates a new BoneAxesViewer
  57809. * @param scene defines the hosting scene
  57810. * @param bone defines the target bone
  57811. * @param mesh defines the target mesh
  57812. * @param scaleLines defines a scaling factor for line length (1 by default)
  57813. */
  57814. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  57815. /**
  57816. * Force the viewer to update
  57817. */
  57818. update(): void;
  57819. /** Releases resources */
  57820. dispose(): void;
  57821. }
  57822. }
  57823. declare module BABYLON {
  57824. /**
  57825. * Interface used to define scene explorer extensibility option
  57826. */
  57827. export interface IExplorerExtensibilityOption {
  57828. /**
  57829. * Define the option label
  57830. */
  57831. label: string;
  57832. /**
  57833. * Defines the action to execute on click
  57834. */
  57835. action: (entity: any) => void;
  57836. }
  57837. /**
  57838. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  57839. */
  57840. export interface IExplorerExtensibilityGroup {
  57841. /**
  57842. * Defines a predicate to test if a given type mut be extended
  57843. */
  57844. predicate: (entity: any) => boolean;
  57845. /**
  57846. * Gets the list of options added to a type
  57847. */
  57848. entries: IExplorerExtensibilityOption[];
  57849. }
  57850. /**
  57851. * Interface used to define the options to use to create the Inspector
  57852. */
  57853. export interface IInspectorOptions {
  57854. /**
  57855. * Display in overlay mode (default: false)
  57856. */
  57857. overlay?: boolean;
  57858. /**
  57859. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  57860. */
  57861. globalRoot?: HTMLElement;
  57862. /**
  57863. * Display the Scene explorer
  57864. */
  57865. showExplorer?: boolean;
  57866. /**
  57867. * Display the property inspector
  57868. */
  57869. showInspector?: boolean;
  57870. /**
  57871. * Display in embed mode (both panes on the right)
  57872. */
  57873. embedMode?: boolean;
  57874. /**
  57875. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  57876. */
  57877. handleResize?: boolean;
  57878. /**
  57879. * Allow the panes to popup (default: true)
  57880. */
  57881. enablePopup?: boolean;
  57882. /**
  57883. * Allow the panes to be closed by users (default: true)
  57884. */
  57885. enableClose?: boolean;
  57886. /**
  57887. * Optional list of extensibility entries
  57888. */
  57889. explorerExtensibility?: IExplorerExtensibilityGroup[];
  57890. /**
  57891. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  57892. */
  57893. inspectorURL?: string;
  57894. /**
  57895. * Optional initial tab (default to DebugLayerTab.Properties)
  57896. */
  57897. initialTab?: DebugLayerTab;
  57898. }
  57899. interface Scene {
  57900. /**
  57901. * @hidden
  57902. * Backing field
  57903. */
  57904. _debugLayer: DebugLayer;
  57905. /**
  57906. * Gets the debug layer (aka Inspector) associated with the scene
  57907. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57908. */
  57909. debugLayer: DebugLayer;
  57910. }
  57911. /**
  57912. * Enum of inspector action tab
  57913. */
  57914. export enum DebugLayerTab {
  57915. /**
  57916. * Properties tag (default)
  57917. */
  57918. Properties = 0,
  57919. /**
  57920. * Debug tab
  57921. */
  57922. Debug = 1,
  57923. /**
  57924. * Statistics tab
  57925. */
  57926. Statistics = 2,
  57927. /**
  57928. * Tools tab
  57929. */
  57930. Tools = 3,
  57931. /**
  57932. * Settings tab
  57933. */
  57934. Settings = 4
  57935. }
  57936. /**
  57937. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57938. * what is happening in your scene
  57939. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57940. */
  57941. export class DebugLayer {
  57942. /**
  57943. * Define the url to get the inspector script from.
  57944. * By default it uses the babylonjs CDN.
  57945. * @ignoreNaming
  57946. */
  57947. static InspectorURL: string;
  57948. private _scene;
  57949. private BJSINSPECTOR;
  57950. private _onPropertyChangedObservable?;
  57951. /**
  57952. * Observable triggered when a property is changed through the inspector.
  57953. */
  57954. get onPropertyChangedObservable(): any;
  57955. /**
  57956. * Instantiates a new debug layer.
  57957. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57958. * what is happening in your scene
  57959. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57960. * @param scene Defines the scene to inspect
  57961. */
  57962. constructor(scene: Scene);
  57963. /** Creates the inspector window. */
  57964. private _createInspector;
  57965. /**
  57966. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  57967. * @param entity defines the entity to select
  57968. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  57969. */
  57970. select(entity: any, lineContainerTitles?: string | string[]): void;
  57971. /** Get the inspector from bundle or global */
  57972. private _getGlobalInspector;
  57973. /**
  57974. * Get if the inspector is visible or not.
  57975. * @returns true if visible otherwise, false
  57976. */
  57977. isVisible(): boolean;
  57978. /**
  57979. * Hide the inspector and close its window.
  57980. */
  57981. hide(): void;
  57982. /**
  57983. * Update the scene in the inspector
  57984. */
  57985. setAsActiveScene(): void;
  57986. /**
  57987. * Launch the debugLayer.
  57988. * @param config Define the configuration of the inspector
  57989. * @return a promise fulfilled when the debug layer is visible
  57990. */
  57991. show(config?: IInspectorOptions): Promise<DebugLayer>;
  57992. }
  57993. }
  57994. declare module BABYLON.Debug {
  57995. /**
  57996. * Used to show the physics impostor around the specific mesh
  57997. */
  57998. export class PhysicsViewer {
  57999. /** @hidden */
  58000. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  58001. /** @hidden */
  58002. protected _meshes: Array<Nullable<AbstractMesh>>;
  58003. /** @hidden */
  58004. protected _scene: Nullable<Scene>;
  58005. /** @hidden */
  58006. protected _numMeshes: number;
  58007. /** @hidden */
  58008. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  58009. private _renderFunction;
  58010. private _utilityLayer;
  58011. private _debugBoxMesh;
  58012. private _debugSphereMesh;
  58013. private _debugCylinderMesh;
  58014. private _debugMaterial;
  58015. private _debugMeshMeshes;
  58016. /**
  58017. * Creates a new PhysicsViewer
  58018. * @param scene defines the hosting scene
  58019. */
  58020. constructor(scene: Scene);
  58021. /** @hidden */
  58022. protected _updateDebugMeshes(): void;
  58023. /**
  58024. * Renders a specified physic impostor
  58025. * @param impostor defines the impostor to render
  58026. * @param targetMesh defines the mesh represented by the impostor
  58027. * @returns the new debug mesh used to render the impostor
  58028. */
  58029. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  58030. /**
  58031. * Hides a specified physic impostor
  58032. * @param impostor defines the impostor to hide
  58033. */
  58034. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  58035. private _getDebugMaterial;
  58036. private _getDebugBoxMesh;
  58037. private _getDebugSphereMesh;
  58038. private _getDebugCylinderMesh;
  58039. private _getDebugMeshMesh;
  58040. private _getDebugMesh;
  58041. /** Releases all resources */
  58042. dispose(): void;
  58043. }
  58044. }
  58045. declare module BABYLON {
  58046. /**
  58047. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58048. * in order to better appreciate the issue one might have.
  58049. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58050. */
  58051. export class RayHelper {
  58052. /**
  58053. * Defines the ray we are currently tryin to visualize.
  58054. */
  58055. ray: Nullable<Ray>;
  58056. private _renderPoints;
  58057. private _renderLine;
  58058. private _renderFunction;
  58059. private _scene;
  58060. private _onAfterRenderObserver;
  58061. private _onAfterStepObserver;
  58062. private _attachedToMesh;
  58063. private _meshSpaceDirection;
  58064. private _meshSpaceOrigin;
  58065. /**
  58066. * Helper function to create a colored helper in a scene in one line.
  58067. * @param ray Defines the ray we are currently tryin to visualize
  58068. * @param scene Defines the scene the ray is used in
  58069. * @param color Defines the color we want to see the ray in
  58070. * @returns The newly created ray helper.
  58071. */
  58072. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58073. /**
  58074. * Instantiate a new ray helper.
  58075. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58076. * in order to better appreciate the issue one might have.
  58077. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58078. * @param ray Defines the ray we are currently tryin to visualize
  58079. */
  58080. constructor(ray: Ray);
  58081. /**
  58082. * Shows the ray we are willing to debug.
  58083. * @param scene Defines the scene the ray needs to be rendered in
  58084. * @param color Defines the color the ray needs to be rendered in
  58085. */
  58086. show(scene: Scene, color?: Color3): void;
  58087. /**
  58088. * Hides the ray we are debugging.
  58089. */
  58090. hide(): void;
  58091. private _render;
  58092. /**
  58093. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58094. * @param mesh Defines the mesh we want the helper attached to
  58095. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58096. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58097. * @param length Defines the length of the ray
  58098. */
  58099. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58100. /**
  58101. * Detach the ray helper from the mesh it has previously been attached to.
  58102. */
  58103. detachFromMesh(): void;
  58104. private _updateToMesh;
  58105. /**
  58106. * Dispose the helper and release its associated resources.
  58107. */
  58108. dispose(): void;
  58109. }
  58110. }
  58111. declare module BABYLON {
  58112. /**
  58113. * Defines the options associated with the creation of a SkeletonViewer.
  58114. */
  58115. export interface ISkeletonViewerOptions {
  58116. /** Should the system pause animations before building the Viewer? */
  58117. pauseAnimations: boolean;
  58118. /** Should the system return the skeleton to rest before building? */
  58119. returnToRest: boolean;
  58120. /** public Display Mode of the Viewer */
  58121. displayMode: number;
  58122. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58123. displayOptions: ISkeletonViewerDisplayOptions;
  58124. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58125. computeBonesUsingShaders: boolean;
  58126. /** Flag ignore non weighted bones */
  58127. useAllBones: boolean;
  58128. }
  58129. /**
  58130. * Defines how to display the various bone meshes for the viewer.
  58131. */
  58132. export interface ISkeletonViewerDisplayOptions {
  58133. /** How far down to start tapering the bone spurs */
  58134. midStep?: number;
  58135. /** How big is the midStep? */
  58136. midStepFactor?: number;
  58137. /** Base for the Sphere Size */
  58138. sphereBaseSize?: number;
  58139. /** The ratio of the sphere to the longest bone in units */
  58140. sphereScaleUnit?: number;
  58141. /** Ratio for the Sphere Size */
  58142. sphereFactor?: number;
  58143. /** Whether a spur should attach its far end to the child bone position */
  58144. spurFollowsChild?: boolean;
  58145. /** Whether to show local axes or not */
  58146. showLocalAxes?: boolean;
  58147. /** Length of each local axis */
  58148. localAxesSize?: number;
  58149. }
  58150. /**
  58151. * Defines the constructor options for the BoneWeight Shader.
  58152. */
  58153. export interface IBoneWeightShaderOptions {
  58154. /** Skeleton to Map */
  58155. skeleton: Skeleton;
  58156. /** Colors for Uninfluenced bones */
  58157. colorBase?: Color3;
  58158. /** Colors for 0.0-0.25 Weight bones */
  58159. colorZero?: Color3;
  58160. /** Color for 0.25-0.5 Weight Influence */
  58161. colorQuarter?: Color3;
  58162. /** Color for 0.5-0.75 Weight Influence */
  58163. colorHalf?: Color3;
  58164. /** Color for 0.75-1 Weight Influence */
  58165. colorFull?: Color3;
  58166. /** Color for Zero Weight Influence */
  58167. targetBoneIndex?: number;
  58168. }
  58169. /**
  58170. * Simple structure of the gradient steps for the Color Map.
  58171. */
  58172. export interface ISkeletonMapShaderColorMapKnot {
  58173. /** Color of the Knot */
  58174. color: Color3;
  58175. /** Location of the Knot */
  58176. location: number;
  58177. }
  58178. /**
  58179. * Defines the constructor options for the SkeletonMap Shader.
  58180. */
  58181. export interface ISkeletonMapShaderOptions {
  58182. /** Skeleton to Map */
  58183. skeleton: Skeleton;
  58184. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58185. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58186. }
  58187. }
  58188. declare module BABYLON {
  58189. /**
  58190. * Class containing static functions to help procedurally build meshes
  58191. */
  58192. export class RibbonBuilder {
  58193. /**
  58194. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58195. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58196. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58197. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58198. * * 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
  58199. * * 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
  58200. * * 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
  58201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58202. * * 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
  58203. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58204. * * 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
  58205. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58206. * * 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
  58207. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58209. * @param name defines the name of the mesh
  58210. * @param options defines the options used to create the mesh
  58211. * @param scene defines the hosting scene
  58212. * @returns the ribbon mesh
  58213. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58214. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58215. */
  58216. static CreateRibbon(name: string, options: {
  58217. pathArray: Vector3[][];
  58218. closeArray?: boolean;
  58219. closePath?: boolean;
  58220. offset?: number;
  58221. updatable?: boolean;
  58222. sideOrientation?: number;
  58223. frontUVs?: Vector4;
  58224. backUVs?: Vector4;
  58225. instance?: Mesh;
  58226. invertUV?: boolean;
  58227. uvs?: Vector2[];
  58228. colors?: Color4[];
  58229. }, scene?: Nullable<Scene>): Mesh;
  58230. }
  58231. }
  58232. declare module BABYLON {
  58233. /**
  58234. * Class containing static functions to help procedurally build meshes
  58235. */
  58236. export class ShapeBuilder {
  58237. /**
  58238. * 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.
  58239. * * 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.
  58240. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58241. * * 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.
  58242. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58243. * * 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
  58244. * * 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
  58245. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58247. * * 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
  58248. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58250. * @param name defines the name of the mesh
  58251. * @param options defines the options used to create the mesh
  58252. * @param scene defines the hosting scene
  58253. * @returns the extruded shape mesh
  58254. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58255. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58256. */
  58257. static ExtrudeShape(name: string, options: {
  58258. shape: Vector3[];
  58259. path: Vector3[];
  58260. scale?: number;
  58261. rotation?: number;
  58262. cap?: number;
  58263. updatable?: boolean;
  58264. sideOrientation?: number;
  58265. frontUVs?: Vector4;
  58266. backUVs?: Vector4;
  58267. instance?: Mesh;
  58268. invertUV?: boolean;
  58269. }, scene?: Nullable<Scene>): Mesh;
  58270. /**
  58271. * Creates an custom extruded shape mesh.
  58272. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58273. * * 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.
  58274. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58275. * * 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
  58276. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58277. * * 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
  58278. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58279. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58280. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58281. * * 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
  58282. * * 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
  58283. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58285. * * 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
  58286. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58288. * @param name defines the name of the mesh
  58289. * @param options defines the options used to create the mesh
  58290. * @param scene defines the hosting scene
  58291. * @returns the custom extruded shape mesh
  58292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58293. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58294. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58295. */
  58296. static ExtrudeShapeCustom(name: string, options: {
  58297. shape: Vector3[];
  58298. path: Vector3[];
  58299. scaleFunction?: any;
  58300. rotationFunction?: any;
  58301. ribbonCloseArray?: boolean;
  58302. ribbonClosePath?: boolean;
  58303. cap?: number;
  58304. updatable?: boolean;
  58305. sideOrientation?: number;
  58306. frontUVs?: Vector4;
  58307. backUVs?: Vector4;
  58308. instance?: Mesh;
  58309. invertUV?: boolean;
  58310. }, scene?: Nullable<Scene>): Mesh;
  58311. private static _ExtrudeShapeGeneric;
  58312. }
  58313. }
  58314. declare module BABYLON.Debug {
  58315. /**
  58316. * Class used to render a debug view of a given skeleton
  58317. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  58318. */
  58319. export class SkeletonViewer {
  58320. /** defines the skeleton to render */
  58321. skeleton: Skeleton;
  58322. /** defines the mesh attached to the skeleton */
  58323. mesh: AbstractMesh;
  58324. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58325. autoUpdateBonesMatrices: boolean;
  58326. /** defines the rendering group id to use with the viewer */
  58327. renderingGroupId: number;
  58328. /** is the options for the viewer */
  58329. options: Partial<ISkeletonViewerOptions>;
  58330. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  58331. static readonly DISPLAY_LINES: number;
  58332. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  58333. static readonly DISPLAY_SPHERES: number;
  58334. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  58335. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  58336. /** public static method to create a BoneWeight Shader
  58337. * @param options The constructor options
  58338. * @param scene The scene that the shader is scoped to
  58339. * @returns The created ShaderMaterial
  58340. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  58341. */
  58342. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  58343. /** public static method to create a BoneWeight Shader
  58344. * @param options The constructor options
  58345. * @param scene The scene that the shader is scoped to
  58346. * @returns The created ShaderMaterial
  58347. */
  58348. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  58349. /** private static method to create a BoneWeight Shader
  58350. * @param size The size of the buffer to create (usually the bone count)
  58351. * @param colorMap The gradient data to generate
  58352. * @param scene The scene that the shader is scoped to
  58353. * @returns an Array of floats from the color gradient values
  58354. */
  58355. private static _CreateBoneMapColorBuffer;
  58356. /** If SkeletonViewer scene scope. */
  58357. private _scene;
  58358. /** Gets or sets the color used to render the skeleton */
  58359. color: Color3;
  58360. /** Array of the points of the skeleton fo the line view. */
  58361. private _debugLines;
  58362. /** The SkeletonViewers Mesh. */
  58363. private _debugMesh;
  58364. /** The local axes Meshes. */
  58365. private _localAxes;
  58366. /** If SkeletonViewer is enabled. */
  58367. private _isEnabled;
  58368. /** If SkeletonViewer is ready. */
  58369. private _ready;
  58370. /** SkeletonViewer render observable. */
  58371. private _obs;
  58372. /** The Utility Layer to render the gizmos in. */
  58373. private _utilityLayer;
  58374. private _boneIndices;
  58375. /** Gets the Scene. */
  58376. get scene(): Scene;
  58377. /** Gets the utilityLayer. */
  58378. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58379. /** Checks Ready Status. */
  58380. get isReady(): Boolean;
  58381. /** Sets Ready Status. */
  58382. set ready(value: boolean);
  58383. /** Gets the debugMesh */
  58384. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58385. /** Sets the debugMesh */
  58386. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58387. /** Gets the displayMode */
  58388. get displayMode(): number;
  58389. /** Sets the displayMode */
  58390. set displayMode(value: number);
  58391. /**
  58392. * Creates a new SkeletonViewer
  58393. * @param skeleton defines the skeleton to render
  58394. * @param mesh defines the mesh attached to the skeleton
  58395. * @param scene defines the hosting scene
  58396. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58397. * @param renderingGroupId defines the rendering group id to use with the viewer
  58398. * @param options All of the extra constructor options for the SkeletonViewer
  58399. */
  58400. constructor(
  58401. /** defines the skeleton to render */
  58402. skeleton: Skeleton,
  58403. /** defines the mesh attached to the skeleton */
  58404. mesh: AbstractMesh,
  58405. /** The Scene scope*/
  58406. scene: Scene,
  58407. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58408. autoUpdateBonesMatrices?: boolean,
  58409. /** defines the rendering group id to use with the viewer */
  58410. renderingGroupId?: number,
  58411. /** is the options for the viewer */
  58412. options?: Partial<ISkeletonViewerOptions>);
  58413. /** The Dynamic bindings for the update functions */
  58414. private _bindObs;
  58415. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58416. update(): void;
  58417. /** Gets or sets a boolean indicating if the viewer is enabled */
  58418. set isEnabled(value: boolean);
  58419. get isEnabled(): boolean;
  58420. private _getBonePosition;
  58421. private _getLinesForBonesWithLength;
  58422. private _getLinesForBonesNoLength;
  58423. /** function to revert the mesh and scene back to the initial state. */
  58424. private _revert;
  58425. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58426. private _getAbsoluteBindPoseToRef;
  58427. /** function to build and bind sphere joint points and spur bone representations. */
  58428. private _buildSpheresAndSpurs;
  58429. private _buildLocalAxes;
  58430. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58431. private _displayLinesUpdate;
  58432. /** Changes the displayMode of the skeleton viewer
  58433. * @param mode The displayMode numerical value
  58434. */
  58435. changeDisplayMode(mode: number): void;
  58436. /** Sets a display option of the skeleton viewer
  58437. *
  58438. * | Option | Type | Default | Description |
  58439. * | ---------------- | ------- | ------- | ----------- |
  58440. * | 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`. |
  58441. * | 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`. |
  58442. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58443. * | 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`. |
  58444. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58445. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58446. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58447. *
  58448. * @param option String of the option name
  58449. * @param value The numerical option value
  58450. */
  58451. changeDisplayOptions(option: string, value: number): void;
  58452. /** Release associated resources */
  58453. dispose(): void;
  58454. }
  58455. }
  58456. declare module BABYLON {
  58457. /**
  58458. * Enum for Device Types
  58459. */
  58460. export enum DeviceType {
  58461. /** Generic */
  58462. Generic = 0,
  58463. /** Keyboard */
  58464. Keyboard = 1,
  58465. /** Mouse */
  58466. Mouse = 2,
  58467. /** Touch Pointers */
  58468. Touch = 3,
  58469. /** PS4 Dual Shock */
  58470. DualShock = 4,
  58471. /** Xbox */
  58472. Xbox = 5,
  58473. /** Switch Controller */
  58474. Switch = 6
  58475. }
  58476. /**
  58477. * Enum for All Pointers (Touch/Mouse)
  58478. */
  58479. export enum PointerInput {
  58480. /** Horizontal Axis */
  58481. Horizontal = 0,
  58482. /** Vertical Axis */
  58483. Vertical = 1,
  58484. /** Left Click or Touch */
  58485. LeftClick = 2,
  58486. /** Middle Click */
  58487. MiddleClick = 3,
  58488. /** Right Click */
  58489. RightClick = 4,
  58490. /** Browser Back */
  58491. BrowserBack = 5,
  58492. /** Browser Forward */
  58493. BrowserForward = 6
  58494. }
  58495. /**
  58496. * Enum for Dual Shock Gamepad
  58497. */
  58498. export enum DualShockInput {
  58499. /** Cross */
  58500. Cross = 0,
  58501. /** Circle */
  58502. Circle = 1,
  58503. /** Square */
  58504. Square = 2,
  58505. /** Triangle */
  58506. Triangle = 3,
  58507. /** L1 */
  58508. L1 = 4,
  58509. /** R1 */
  58510. R1 = 5,
  58511. /** L2 */
  58512. L2 = 6,
  58513. /** R2 */
  58514. R2 = 7,
  58515. /** Share */
  58516. Share = 8,
  58517. /** Options */
  58518. Options = 9,
  58519. /** L3 */
  58520. L3 = 10,
  58521. /** R3 */
  58522. R3 = 11,
  58523. /** DPadUp */
  58524. DPadUp = 12,
  58525. /** DPadDown */
  58526. DPadDown = 13,
  58527. /** DPadLeft */
  58528. DPadLeft = 14,
  58529. /** DRight */
  58530. DPadRight = 15,
  58531. /** Home */
  58532. Home = 16,
  58533. /** TouchPad */
  58534. TouchPad = 17,
  58535. /** LStickXAxis */
  58536. LStickXAxis = 18,
  58537. /** LStickYAxis */
  58538. LStickYAxis = 19,
  58539. /** RStickXAxis */
  58540. RStickXAxis = 20,
  58541. /** RStickYAxis */
  58542. RStickYAxis = 21
  58543. }
  58544. /**
  58545. * Enum for Xbox Gamepad
  58546. */
  58547. export enum XboxInput {
  58548. /** A */
  58549. A = 0,
  58550. /** B */
  58551. B = 1,
  58552. /** X */
  58553. X = 2,
  58554. /** Y */
  58555. Y = 3,
  58556. /** LB */
  58557. LB = 4,
  58558. /** RB */
  58559. RB = 5,
  58560. /** LT */
  58561. LT = 6,
  58562. /** RT */
  58563. RT = 7,
  58564. /** Back */
  58565. Back = 8,
  58566. /** Start */
  58567. Start = 9,
  58568. /** LS */
  58569. LS = 10,
  58570. /** RS */
  58571. RS = 11,
  58572. /** DPadUp */
  58573. DPadUp = 12,
  58574. /** DPadDown */
  58575. DPadDown = 13,
  58576. /** DPadLeft */
  58577. DPadLeft = 14,
  58578. /** DRight */
  58579. DPadRight = 15,
  58580. /** Home */
  58581. Home = 16,
  58582. /** LStickXAxis */
  58583. LStickXAxis = 17,
  58584. /** LStickYAxis */
  58585. LStickYAxis = 18,
  58586. /** RStickXAxis */
  58587. RStickXAxis = 19,
  58588. /** RStickYAxis */
  58589. RStickYAxis = 20
  58590. }
  58591. /**
  58592. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58593. */
  58594. export enum SwitchInput {
  58595. /** B */
  58596. B = 0,
  58597. /** A */
  58598. A = 1,
  58599. /** Y */
  58600. Y = 2,
  58601. /** X */
  58602. X = 3,
  58603. /** L */
  58604. L = 4,
  58605. /** R */
  58606. R = 5,
  58607. /** ZL */
  58608. ZL = 6,
  58609. /** ZR */
  58610. ZR = 7,
  58611. /** Minus */
  58612. Minus = 8,
  58613. /** Plus */
  58614. Plus = 9,
  58615. /** LS */
  58616. LS = 10,
  58617. /** RS */
  58618. RS = 11,
  58619. /** DPadUp */
  58620. DPadUp = 12,
  58621. /** DPadDown */
  58622. DPadDown = 13,
  58623. /** DPadLeft */
  58624. DPadLeft = 14,
  58625. /** DRight */
  58626. DPadRight = 15,
  58627. /** Home */
  58628. Home = 16,
  58629. /** Capture */
  58630. Capture = 17,
  58631. /** LStickXAxis */
  58632. LStickXAxis = 18,
  58633. /** LStickYAxis */
  58634. LStickYAxis = 19,
  58635. /** RStickXAxis */
  58636. RStickXAxis = 20,
  58637. /** RStickYAxis */
  58638. RStickYAxis = 21
  58639. }
  58640. }
  58641. declare module BABYLON {
  58642. /**
  58643. * This class will take all inputs from Keyboard, Pointer, and
  58644. * any Gamepads and provide a polling system that all devices
  58645. * will use. This class assumes that there will only be one
  58646. * pointer device and one keyboard.
  58647. */
  58648. export class DeviceInputSystem implements IDisposable {
  58649. /**
  58650. * Returns onDeviceConnected callback property
  58651. * @returns Callback with function to execute when a device is connected
  58652. */
  58653. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58654. /**
  58655. * Sets callback function when a device is connected and executes against all connected devices
  58656. * @param callback Function to execute when a device is connected
  58657. */
  58658. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58659. /**
  58660. * Callback to be triggered when a device is disconnected
  58661. */
  58662. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58663. /**
  58664. * Callback to be triggered when event driven input is updated
  58665. */
  58666. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58667. private _inputs;
  58668. private _gamepads;
  58669. private _keyboardActive;
  58670. private _pointerActive;
  58671. private _elementToAttachTo;
  58672. private _keyboardDownEvent;
  58673. private _keyboardUpEvent;
  58674. private _pointerMoveEvent;
  58675. private _pointerDownEvent;
  58676. private _pointerUpEvent;
  58677. private _gamepadConnectedEvent;
  58678. private _gamepadDisconnectedEvent;
  58679. private _onDeviceConnected;
  58680. private static _MAX_KEYCODES;
  58681. private static _MAX_POINTER_INPUTS;
  58682. private constructor();
  58683. /**
  58684. * Creates a new DeviceInputSystem instance
  58685. * @param engine Engine to pull input element from
  58686. * @returns The new instance
  58687. */
  58688. static Create(engine: Engine): DeviceInputSystem;
  58689. /**
  58690. * Checks for current device input value, given an id and input index
  58691. * @param deviceName Id of connected device
  58692. * @param inputIndex Index of device input
  58693. * @returns Current value of input
  58694. */
  58695. /**
  58696. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58697. * @param deviceType Enum specifiying device type
  58698. * @param deviceSlot "Slot" or index that device is referenced in
  58699. * @param inputIndex Id of input to be checked
  58700. * @returns Current value of input
  58701. */
  58702. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58703. /**
  58704. * Dispose of all the eventlisteners
  58705. */
  58706. dispose(): void;
  58707. /**
  58708. * Checks for existing connections to devices and register them, if necessary
  58709. * Currently handles gamepads and mouse
  58710. */
  58711. private _checkForConnectedDevices;
  58712. /**
  58713. * Add a gamepad to the DeviceInputSystem
  58714. * @param gamepad A single DOM Gamepad object
  58715. */
  58716. private _addGamePad;
  58717. /**
  58718. * Add pointer device to DeviceInputSystem
  58719. * @param deviceType Type of Pointer to add
  58720. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  58721. * @param currentX Current X at point of adding
  58722. * @param currentY Current Y at point of adding
  58723. */
  58724. private _addPointerDevice;
  58725. /**
  58726. * Add device and inputs to device array
  58727. * @param deviceType Enum specifiying device type
  58728. * @param deviceSlot "Slot" or index that device is referenced in
  58729. * @param numberOfInputs Number of input entries to create for given device
  58730. */
  58731. private _registerDevice;
  58732. /**
  58733. * Given a specific device name, remove that device from the device map
  58734. * @param deviceType Enum specifiying device type
  58735. * @param deviceSlot "Slot" or index that device is referenced in
  58736. */
  58737. private _unregisterDevice;
  58738. /**
  58739. * Handle all actions that come from keyboard interaction
  58740. */
  58741. private _handleKeyActions;
  58742. /**
  58743. * Handle all actions that come from pointer interaction
  58744. */
  58745. private _handlePointerActions;
  58746. /**
  58747. * Handle all actions that come from gamepad interaction
  58748. */
  58749. private _handleGamepadActions;
  58750. /**
  58751. * Update all non-event based devices with each frame
  58752. * @param deviceType Enum specifiying device type
  58753. * @param deviceSlot "Slot" or index that device is referenced in
  58754. * @param inputIndex Id of input to be checked
  58755. */
  58756. private _updateDevice;
  58757. /**
  58758. * Gets DeviceType from the device name
  58759. * @param deviceName Name of Device from DeviceInputSystem
  58760. * @returns DeviceType enum value
  58761. */
  58762. private _getGamepadDeviceType;
  58763. }
  58764. }
  58765. declare module BABYLON {
  58766. /**
  58767. * Type to handle enforcement of inputs
  58768. */
  58769. 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;
  58770. }
  58771. declare module BABYLON {
  58772. /**
  58773. * Class that handles all input for a specific device
  58774. */
  58775. export class DeviceSource<T extends DeviceType> {
  58776. /** Type of device */
  58777. readonly deviceType: DeviceType;
  58778. /** "Slot" or index that device is referenced in */
  58779. readonly deviceSlot: number;
  58780. /**
  58781. * Observable to handle device input changes per device
  58782. */
  58783. readonly onInputChangedObservable: Observable<{
  58784. inputIndex: DeviceInput<T>;
  58785. previousState: Nullable<number>;
  58786. currentState: Nullable<number>;
  58787. }>;
  58788. private readonly _deviceInputSystem;
  58789. /**
  58790. * Default Constructor
  58791. * @param deviceInputSystem Reference to DeviceInputSystem
  58792. * @param deviceType Type of device
  58793. * @param deviceSlot "Slot" or index that device is referenced in
  58794. */
  58795. constructor(deviceInputSystem: DeviceInputSystem,
  58796. /** Type of device */
  58797. deviceType: DeviceType,
  58798. /** "Slot" or index that device is referenced in */
  58799. deviceSlot?: number);
  58800. /**
  58801. * Get input for specific input
  58802. * @param inputIndex index of specific input on device
  58803. * @returns Input value from DeviceInputSystem
  58804. */
  58805. getInput(inputIndex: DeviceInput<T>): number;
  58806. }
  58807. /**
  58808. * Class to keep track of devices
  58809. */
  58810. export class DeviceSourceManager implements IDisposable {
  58811. /**
  58812. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  58813. */
  58814. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  58815. /**
  58816. * Observable to be triggered when after a device is disconnected
  58817. */
  58818. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  58819. private readonly _devices;
  58820. private readonly _firstDevice;
  58821. private readonly _deviceInputSystem;
  58822. /**
  58823. * Default Constructor
  58824. * @param engine engine to pull input element from
  58825. */
  58826. constructor(engine: Engine);
  58827. /**
  58828. * Gets a DeviceSource, given a type and slot
  58829. * @param deviceType Enum specifying device type
  58830. * @param deviceSlot "Slot" or index that device is referenced in
  58831. * @returns DeviceSource object
  58832. */
  58833. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  58834. /**
  58835. * Gets an array of DeviceSource objects for a given device type
  58836. * @param deviceType Enum specifying device type
  58837. * @returns Array of DeviceSource objects
  58838. */
  58839. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  58840. /**
  58841. * Returns a read-only list of all available devices
  58842. * @returns Read-only array with active devices
  58843. */
  58844. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  58845. /**
  58846. * Dispose of DeviceInputSystem and other parts
  58847. */
  58848. dispose(): void;
  58849. /**
  58850. * Function to add device name to device list
  58851. * @param deviceType Enum specifying device type
  58852. * @param deviceSlot "Slot" or index that device is referenced in
  58853. */
  58854. private _addDevice;
  58855. /**
  58856. * Function to remove device name to device list
  58857. * @param deviceType Enum specifying device type
  58858. * @param deviceSlot "Slot" or index that device is referenced in
  58859. */
  58860. private _removeDevice;
  58861. /**
  58862. * Updates array storing first connected device of each type
  58863. * @param type Type of Device
  58864. */
  58865. private _updateFirstDevices;
  58866. }
  58867. }
  58868. declare module BABYLON {
  58869. /**
  58870. * Options to create the null engine
  58871. */
  58872. export class NullEngineOptions {
  58873. /**
  58874. * Render width (Default: 512)
  58875. */
  58876. renderWidth: number;
  58877. /**
  58878. * Render height (Default: 256)
  58879. */
  58880. renderHeight: number;
  58881. /**
  58882. * Texture size (Default: 512)
  58883. */
  58884. textureSize: number;
  58885. /**
  58886. * If delta time between frames should be constant
  58887. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58888. */
  58889. deterministicLockstep: boolean;
  58890. /**
  58891. * Maximum about of steps between frames (Default: 4)
  58892. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58893. */
  58894. lockstepMaxSteps: number;
  58895. /**
  58896. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  58897. */
  58898. useHighPrecisionMatrix?: boolean;
  58899. }
  58900. /**
  58901. * The null engine class provides support for headless version of babylon.js.
  58902. * This can be used in server side scenario or for testing purposes
  58903. */
  58904. export class NullEngine extends Engine {
  58905. private _options;
  58906. /**
  58907. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  58908. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58909. * @returns true if engine is in deterministic lock step mode
  58910. */
  58911. isDeterministicLockStep(): boolean;
  58912. /**
  58913. * Gets the max steps when engine is running in deterministic lock step
  58914. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58915. * @returns the max steps
  58916. */
  58917. getLockstepMaxSteps(): number;
  58918. /**
  58919. * Gets the current hardware scaling level.
  58920. * By default the hardware scaling level is computed from the window device ratio.
  58921. * 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.
  58922. * @returns a number indicating the current hardware scaling level
  58923. */
  58924. getHardwareScalingLevel(): number;
  58925. constructor(options?: NullEngineOptions);
  58926. /**
  58927. * Creates a vertex buffer
  58928. * @param vertices the data for the vertex buffer
  58929. * @returns the new WebGL static buffer
  58930. */
  58931. createVertexBuffer(vertices: FloatArray): DataBuffer;
  58932. /**
  58933. * Creates a new index buffer
  58934. * @param indices defines the content of the index buffer
  58935. * @param updatable defines if the index buffer must be updatable
  58936. * @returns a new webGL buffer
  58937. */
  58938. createIndexBuffer(indices: IndicesArray): DataBuffer;
  58939. /**
  58940. * Clear the current render buffer or the current render target (if any is set up)
  58941. * @param color defines the color to use
  58942. * @param backBuffer defines if the back buffer must be cleared
  58943. * @param depth defines if the depth buffer must be cleared
  58944. * @param stencil defines if the stencil buffer must be cleared
  58945. */
  58946. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58947. /**
  58948. * Gets the current render width
  58949. * @param useScreen defines if screen size must be used (or the current render target if any)
  58950. * @returns a number defining the current render width
  58951. */
  58952. getRenderWidth(useScreen?: boolean): number;
  58953. /**
  58954. * Gets the current render height
  58955. * @param useScreen defines if screen size must be used (or the current render target if any)
  58956. * @returns a number defining the current render height
  58957. */
  58958. getRenderHeight(useScreen?: boolean): number;
  58959. /**
  58960. * Set the WebGL's viewport
  58961. * @param viewport defines the viewport element to be used
  58962. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  58963. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  58964. */
  58965. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  58966. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  58967. /**
  58968. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  58969. * @param pipelineContext defines the pipeline context to use
  58970. * @param uniformsNames defines the list of uniform names
  58971. * @returns an array of webGL uniform locations
  58972. */
  58973. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  58974. /**
  58975. * Gets the lsit of active attributes for a given webGL program
  58976. * @param pipelineContext defines the pipeline context to use
  58977. * @param attributesNames defines the list of attribute names to get
  58978. * @returns an array of indices indicating the offset of each attribute
  58979. */
  58980. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58981. /**
  58982. * Binds an effect to the webGL context
  58983. * @param effect defines the effect to bind
  58984. */
  58985. bindSamplers(effect: Effect): void;
  58986. /**
  58987. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  58988. * @param effect defines the effect to activate
  58989. */
  58990. enableEffect(effect: Effect): void;
  58991. /**
  58992. * Set various states to the webGL context
  58993. * @param culling defines backface culling state
  58994. * @param zOffset defines the value to apply to zOffset (0 by default)
  58995. * @param force defines if states must be applied even if cache is up to date
  58996. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  58997. */
  58998. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58999. /**
  59000. * Set the value of an uniform to an array of int32
  59001. * @param uniform defines the webGL uniform location where to store the value
  59002. * @param array defines the array of int32 to store
  59003. * @returns true if value was set
  59004. */
  59005. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59006. /**
  59007. * Set the value of an uniform to an array of int32 (stored as vec2)
  59008. * @param uniform defines the webGL uniform location where to store the value
  59009. * @param array defines the array of int32 to store
  59010. * @returns true if value was set
  59011. */
  59012. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59013. /**
  59014. * Set the value of an uniform to an array of int32 (stored as vec3)
  59015. * @param uniform defines the webGL uniform location where to store the value
  59016. * @param array defines the array of int32 to store
  59017. * @returns true if value was set
  59018. */
  59019. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59020. /**
  59021. * Set the value of an uniform to an array of int32 (stored as vec4)
  59022. * @param uniform defines the webGL uniform location where to store the value
  59023. * @param array defines the array of int32 to store
  59024. * @returns true if value was set
  59025. */
  59026. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59027. /**
  59028. * Set the value of an uniform to an array of float32
  59029. * @param uniform defines the webGL uniform location where to store the value
  59030. * @param array defines the array of float32 to store
  59031. * @returns true if value was set
  59032. */
  59033. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59034. /**
  59035. * Set the value of an uniform to an array of float32 (stored as vec2)
  59036. * @param uniform defines the webGL uniform location where to store the value
  59037. * @param array defines the array of float32 to store
  59038. * @returns true if value was set
  59039. */
  59040. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59041. /**
  59042. * Set the value of an uniform to an array of float32 (stored as vec3)
  59043. * @param uniform defines the webGL uniform location where to store the value
  59044. * @param array defines the array of float32 to store
  59045. * @returns true if value was set
  59046. */
  59047. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59048. /**
  59049. * Set the value of an uniform to an array of float32 (stored as vec4)
  59050. * @param uniform defines the webGL uniform location where to store the value
  59051. * @param array defines the array of float32 to store
  59052. * @returns true if value was set
  59053. */
  59054. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59055. /**
  59056. * Set the value of an uniform to an array of number
  59057. * @param uniform defines the webGL uniform location where to store the value
  59058. * @param array defines the array of number to store
  59059. * @returns true if value was set
  59060. */
  59061. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59062. /**
  59063. * Set the value of an uniform to an array of number (stored as vec2)
  59064. * @param uniform defines the webGL uniform location where to store the value
  59065. * @param array defines the array of number to store
  59066. * @returns true if value was set
  59067. */
  59068. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59069. /**
  59070. * Set the value of an uniform to an array of number (stored as vec3)
  59071. * @param uniform defines the webGL uniform location where to store the value
  59072. * @param array defines the array of number to store
  59073. * @returns true if value was set
  59074. */
  59075. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59076. /**
  59077. * Set the value of an uniform to an array of number (stored as vec4)
  59078. * @param uniform defines the webGL uniform location where to store the value
  59079. * @param array defines the array of number to store
  59080. * @returns true if value was set
  59081. */
  59082. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59083. /**
  59084. * Set the value of an uniform to an array of float32 (stored as matrices)
  59085. * @param uniform defines the webGL uniform location where to store the value
  59086. * @param matrices defines the array of float32 to store
  59087. * @returns true if value was set
  59088. */
  59089. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59090. /**
  59091. * Set the value of an uniform to a matrix (3x3)
  59092. * @param uniform defines the webGL uniform location where to store the value
  59093. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59094. * @returns true if value was set
  59095. */
  59096. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59097. /**
  59098. * Set the value of an uniform to a matrix (2x2)
  59099. * @param uniform defines the webGL uniform location where to store the value
  59100. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59101. * @returns true if value was set
  59102. */
  59103. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59104. /**
  59105. * Set the value of an uniform to a number (float)
  59106. * @param uniform defines the webGL uniform location where to store the value
  59107. * @param value defines the float number to store
  59108. * @returns true if value was set
  59109. */
  59110. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59111. /**
  59112. * Set the value of an uniform to a vec2
  59113. * @param uniform defines the webGL uniform location where to store the value
  59114. * @param x defines the 1st component of the value
  59115. * @param y defines the 2nd component of the value
  59116. * @returns true if value was set
  59117. */
  59118. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59119. /**
  59120. * Set the value of an uniform to a vec3
  59121. * @param uniform defines the webGL uniform location where to store the value
  59122. * @param x defines the 1st component of the value
  59123. * @param y defines the 2nd component of the value
  59124. * @param z defines the 3rd component of the value
  59125. * @returns true if value was set
  59126. */
  59127. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59128. /**
  59129. * Set the value of an uniform to a boolean
  59130. * @param uniform defines the webGL uniform location where to store the value
  59131. * @param bool defines the boolean to store
  59132. * @returns true if value was set
  59133. */
  59134. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59135. /**
  59136. * Set the value of an uniform to a vec4
  59137. * @param uniform defines the webGL uniform location where to store the value
  59138. * @param x defines the 1st component of the value
  59139. * @param y defines the 2nd component of the value
  59140. * @param z defines the 3rd component of the value
  59141. * @param w defines the 4th component of the value
  59142. * @returns true if value was set
  59143. */
  59144. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59145. /**
  59146. * Sets the current alpha mode
  59147. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59148. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59149. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59150. */
  59151. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59152. /**
  59153. * Bind webGl buffers directly to the webGL context
  59154. * @param vertexBuffers defines the vertex buffer to bind
  59155. * @param indexBuffer defines the index buffer to bind
  59156. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59157. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59158. * @param effect defines the effect associated with the vertex buffer
  59159. */
  59160. bindBuffers(vertexBuffers: {
  59161. [key: string]: VertexBuffer;
  59162. }, indexBuffer: DataBuffer, effect: Effect): void;
  59163. /**
  59164. * Force the entire cache to be cleared
  59165. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59166. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59167. */
  59168. wipeCaches(bruteForce?: boolean): void;
  59169. /**
  59170. * Send a draw order
  59171. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59172. * @param indexStart defines the starting index
  59173. * @param indexCount defines the number of index to draw
  59174. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59175. */
  59176. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59177. /**
  59178. * Draw a list of indexed primitives
  59179. * @param fillMode defines the primitive to use
  59180. * @param indexStart defines the starting index
  59181. * @param indexCount defines the number of index to draw
  59182. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59183. */
  59184. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59185. /**
  59186. * Draw a list of unindexed primitives
  59187. * @param fillMode defines the primitive to use
  59188. * @param verticesStart defines the index of first vertex to draw
  59189. * @param verticesCount defines the count of vertices to draw
  59190. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59191. */
  59192. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59193. /** @hidden */
  59194. protected _createTexture(): WebGLTexture;
  59195. /** @hidden */
  59196. _releaseTexture(texture: InternalTexture): void;
  59197. /**
  59198. * Usually called from Texture.ts.
  59199. * Passed information to create a WebGLTexture
  59200. * @param urlArg defines a value which contains one of the following:
  59201. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59202. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59203. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59204. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59205. * @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)
  59206. * @param scene needed for loading to the correct scene
  59207. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59208. * @param onLoad optional callback to be called upon successful completion
  59209. * @param onError optional callback to be called upon failure
  59210. * @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
  59211. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59212. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59213. * @param forcedExtension defines the extension to use to pick the right loader
  59214. * @param mimeType defines an optional mime type
  59215. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59216. */
  59217. 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;
  59218. /**
  59219. * Creates a new render target texture
  59220. * @param size defines the size of the texture
  59221. * @param options defines the options used to create the texture
  59222. * @returns a new render target texture stored in an InternalTexture
  59223. */
  59224. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59225. /**
  59226. * Update the sampling mode of a given texture
  59227. * @param samplingMode defines the required sampling mode
  59228. * @param texture defines the texture to update
  59229. */
  59230. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59231. /**
  59232. * Binds the frame buffer to the specified texture.
  59233. * @param texture The texture to render to or null for the default canvas
  59234. * @param faceIndex The face of the texture to render to in case of cube texture
  59235. * @param requiredWidth The width of the target to render to
  59236. * @param requiredHeight The height of the target to render to
  59237. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59238. * @param lodLevel defines le lod level to bind to the frame buffer
  59239. */
  59240. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59241. /**
  59242. * Unbind the current render target texture from the webGL context
  59243. * @param texture defines the render target texture to unbind
  59244. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  59245. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  59246. */
  59247. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59248. /**
  59249. * Creates a dynamic vertex buffer
  59250. * @param vertices the data for the dynamic vertex buffer
  59251. * @returns the new WebGL dynamic buffer
  59252. */
  59253. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  59254. /**
  59255. * Update the content of a dynamic texture
  59256. * @param texture defines the texture to update
  59257. * @param canvas defines the canvas containing the source
  59258. * @param invertY defines if data must be stored with Y axis inverted
  59259. * @param premulAlpha defines if alpha is stored as premultiplied
  59260. * @param format defines the format of the data
  59261. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59262. */
  59263. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59264. /**
  59265. * Gets a boolean indicating if all created effects are ready
  59266. * @returns true if all effects are ready
  59267. */
  59268. areAllEffectsReady(): boolean;
  59269. /**
  59270. * @hidden
  59271. * Get the current error code of the webGL context
  59272. * @returns the error code
  59273. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  59274. */
  59275. getError(): number;
  59276. /** @hidden */
  59277. _getUnpackAlignement(): number;
  59278. /** @hidden */
  59279. _unpackFlipY(value: boolean): void;
  59280. /**
  59281. * Update a dynamic index buffer
  59282. * @param indexBuffer defines the target index buffer
  59283. * @param indices defines the data to update
  59284. * @param offset defines the offset in the target index buffer where update should start
  59285. */
  59286. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  59287. /**
  59288. * Updates a dynamic vertex buffer.
  59289. * @param vertexBuffer the vertex buffer to update
  59290. * @param vertices the data used to update the vertex buffer
  59291. * @param byteOffset the byte offset of the data (optional)
  59292. * @param byteLength the byte length of the data (optional)
  59293. */
  59294. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  59295. /** @hidden */
  59296. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  59297. /** @hidden */
  59298. _bindTexture(channel: number, texture: InternalTexture): void;
  59299. protected _deleteBuffer(buffer: WebGLBuffer): void;
  59300. /**
  59301. * 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
  59302. */
  59303. releaseEffects(): void;
  59304. displayLoadingUI(): void;
  59305. hideLoadingUI(): void;
  59306. /** @hidden */
  59307. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59308. /** @hidden */
  59309. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59310. /** @hidden */
  59311. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59312. /** @hidden */
  59313. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59314. }
  59315. }
  59316. declare module BABYLON {
  59317. /** @hidden */
  59318. export class _OcclusionDataStorage {
  59319. /** @hidden */
  59320. occlusionInternalRetryCounter: number;
  59321. /** @hidden */
  59322. isOcclusionQueryInProgress: boolean;
  59323. /** @hidden */
  59324. isOccluded: boolean;
  59325. /** @hidden */
  59326. occlusionRetryCount: number;
  59327. /** @hidden */
  59328. occlusionType: number;
  59329. /** @hidden */
  59330. occlusionQueryAlgorithmType: number;
  59331. }
  59332. interface Engine {
  59333. /**
  59334. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59335. * @return the new query
  59336. */
  59337. createQuery(): WebGLQuery;
  59338. /**
  59339. * Delete and release a webGL query
  59340. * @param query defines the query to delete
  59341. * @return the current engine
  59342. */
  59343. deleteQuery(query: WebGLQuery): Engine;
  59344. /**
  59345. * Check if a given query has resolved and got its value
  59346. * @param query defines the query to check
  59347. * @returns true if the query got its value
  59348. */
  59349. isQueryResultAvailable(query: WebGLQuery): boolean;
  59350. /**
  59351. * Gets the value of a given query
  59352. * @param query defines the query to check
  59353. * @returns the value of the query
  59354. */
  59355. getQueryResult(query: WebGLQuery): number;
  59356. /**
  59357. * Initiates an occlusion query
  59358. * @param algorithmType defines the algorithm to use
  59359. * @param query defines the query to use
  59360. * @returns the current engine
  59361. * @see https://doc.babylonjs.com/features/occlusionquery
  59362. */
  59363. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59364. /**
  59365. * Ends an occlusion query
  59366. * @see https://doc.babylonjs.com/features/occlusionquery
  59367. * @param algorithmType defines the algorithm to use
  59368. * @returns the current engine
  59369. */
  59370. endOcclusionQuery(algorithmType: number): Engine;
  59371. /**
  59372. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59373. * Please note that only one query can be issued at a time
  59374. * @returns a time token used to track the time span
  59375. */
  59376. startTimeQuery(): Nullable<_TimeToken>;
  59377. /**
  59378. * Ends a time query
  59379. * @param token defines the token used to measure the time span
  59380. * @returns the time spent (in ns)
  59381. */
  59382. endTimeQuery(token: _TimeToken): int;
  59383. /** @hidden */
  59384. _currentNonTimestampToken: Nullable<_TimeToken>;
  59385. /** @hidden */
  59386. _createTimeQuery(): WebGLQuery;
  59387. /** @hidden */
  59388. _deleteTimeQuery(query: WebGLQuery): void;
  59389. /** @hidden */
  59390. _getGlAlgorithmType(algorithmType: number): number;
  59391. /** @hidden */
  59392. _getTimeQueryResult(query: WebGLQuery): any;
  59393. /** @hidden */
  59394. _getTimeQueryAvailability(query: WebGLQuery): any;
  59395. }
  59396. interface AbstractMesh {
  59397. /**
  59398. * Backing filed
  59399. * @hidden
  59400. */
  59401. __occlusionDataStorage: _OcclusionDataStorage;
  59402. /**
  59403. * Access property
  59404. * @hidden
  59405. */
  59406. _occlusionDataStorage: _OcclusionDataStorage;
  59407. /**
  59408. * 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.
  59409. * The default value is -1 which means don't break the query and wait till the result
  59410. * @see https://doc.babylonjs.com/features/occlusionquery
  59411. */
  59412. occlusionRetryCount: number;
  59413. /**
  59414. * 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:
  59415. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59416. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59417. * * 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.
  59418. * @see https://doc.babylonjs.com/features/occlusionquery
  59419. */
  59420. occlusionType: number;
  59421. /**
  59422. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59423. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59424. * * 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.
  59425. * @see https://doc.babylonjs.com/features/occlusionquery
  59426. */
  59427. occlusionQueryAlgorithmType: number;
  59428. /**
  59429. * 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
  59430. * @see https://doc.babylonjs.com/features/occlusionquery
  59431. */
  59432. isOccluded: boolean;
  59433. /**
  59434. * Flag to check the progress status of the query
  59435. * @see https://doc.babylonjs.com/features/occlusionquery
  59436. */
  59437. isOcclusionQueryInProgress: boolean;
  59438. }
  59439. }
  59440. declare module BABYLON {
  59441. /** @hidden */
  59442. export var _forceTransformFeedbackToBundle: boolean;
  59443. interface Engine {
  59444. /**
  59445. * Creates a webGL transform feedback object
  59446. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59447. * @returns the webGL transform feedback object
  59448. */
  59449. createTransformFeedback(): WebGLTransformFeedback;
  59450. /**
  59451. * Delete a webGL transform feedback object
  59452. * @param value defines the webGL transform feedback object to delete
  59453. */
  59454. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59455. /**
  59456. * Bind a webGL transform feedback object to the webgl context
  59457. * @param value defines the webGL transform feedback object to bind
  59458. */
  59459. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59460. /**
  59461. * Begins a transform feedback operation
  59462. * @param usePoints defines if points or triangles must be used
  59463. */
  59464. beginTransformFeedback(usePoints: boolean): void;
  59465. /**
  59466. * Ends a transform feedback operation
  59467. */
  59468. endTransformFeedback(): void;
  59469. /**
  59470. * Specify the varyings to use with transform feedback
  59471. * @param program defines the associated webGL program
  59472. * @param value defines the list of strings representing the varying names
  59473. */
  59474. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59475. /**
  59476. * Bind a webGL buffer for a transform feedback operation
  59477. * @param value defines the webGL buffer to bind
  59478. */
  59479. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59480. }
  59481. }
  59482. declare module BABYLON {
  59483. /**
  59484. * Class used to define an additional view for the engine
  59485. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59486. */
  59487. export class EngineView {
  59488. /** Defines the canvas where to render the view */
  59489. target: HTMLCanvasElement;
  59490. /** Defines an optional camera used to render the view (will use active camera else) */
  59491. camera?: Camera;
  59492. }
  59493. interface Engine {
  59494. /**
  59495. * Gets or sets the HTML element to use for attaching events
  59496. */
  59497. inputElement: Nullable<HTMLElement>;
  59498. /**
  59499. * Gets the current engine view
  59500. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59501. */
  59502. activeView: Nullable<EngineView>;
  59503. /** Gets or sets the list of views */
  59504. views: EngineView[];
  59505. /**
  59506. * Register a new child canvas
  59507. * @param canvas defines the canvas to register
  59508. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59509. * @returns the associated view
  59510. */
  59511. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59512. /**
  59513. * Remove a registered child canvas
  59514. * @param canvas defines the canvas to remove
  59515. * @returns the current engine
  59516. */
  59517. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59518. }
  59519. }
  59520. declare module BABYLON {
  59521. interface Engine {
  59522. /** @hidden */
  59523. _excludedCompressedTextures: string[];
  59524. /** @hidden */
  59525. _textureFormatInUse: string;
  59526. /**
  59527. * Gets the list of texture formats supported
  59528. */
  59529. readonly texturesSupported: Array<string>;
  59530. /**
  59531. * Gets the texture format in use
  59532. */
  59533. readonly textureFormatInUse: Nullable<string>;
  59534. /**
  59535. * Set the compressed texture extensions or file names to skip.
  59536. *
  59537. * @param skippedFiles defines the list of those texture files you want to skip
  59538. * Example: [".dds", ".env", "myfile.png"]
  59539. */
  59540. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59541. /**
  59542. * Set the compressed texture format to use, based on the formats you have, and the formats
  59543. * supported by the hardware / browser.
  59544. *
  59545. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59546. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59547. * to API arguments needed to compressed textures. This puts the burden on the container
  59548. * generator to house the arcane code for determining these for current & future formats.
  59549. *
  59550. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59551. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59552. *
  59553. * Note: The result of this call is not taken into account when a texture is base64.
  59554. *
  59555. * @param formatsAvailable defines the list of those format families you have created
  59556. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59557. *
  59558. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59559. * @returns The extension selected.
  59560. */
  59561. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59562. }
  59563. }
  59564. declare module BABYLON {
  59565. /** @hidden */
  59566. export var rgbdEncodePixelShader: {
  59567. name: string;
  59568. shader: string;
  59569. };
  59570. }
  59571. declare module BABYLON {
  59572. /**
  59573. * Raw texture data and descriptor sufficient for WebGL texture upload
  59574. */
  59575. export interface EnvironmentTextureInfo {
  59576. /**
  59577. * Version of the environment map
  59578. */
  59579. version: number;
  59580. /**
  59581. * Width of image
  59582. */
  59583. width: number;
  59584. /**
  59585. * Irradiance information stored in the file.
  59586. */
  59587. irradiance: any;
  59588. /**
  59589. * Specular information stored in the file.
  59590. */
  59591. specular: any;
  59592. }
  59593. /**
  59594. * Defines One Image in the file. It requires only the position in the file
  59595. * as well as the length.
  59596. */
  59597. interface BufferImageData {
  59598. /**
  59599. * Length of the image data.
  59600. */
  59601. length: number;
  59602. /**
  59603. * Position of the data from the null terminator delimiting the end of the JSON.
  59604. */
  59605. position: number;
  59606. }
  59607. /**
  59608. * Defines the specular data enclosed in the file.
  59609. * This corresponds to the version 1 of the data.
  59610. */
  59611. export interface EnvironmentTextureSpecularInfoV1 {
  59612. /**
  59613. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59614. */
  59615. specularDataPosition?: number;
  59616. /**
  59617. * This contains all the images data needed to reconstruct the cubemap.
  59618. */
  59619. mipmaps: Array<BufferImageData>;
  59620. /**
  59621. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59622. */
  59623. lodGenerationScale: number;
  59624. }
  59625. /**
  59626. * Sets of helpers addressing the serialization and deserialization of environment texture
  59627. * stored in a BabylonJS env file.
  59628. * Those files are usually stored as .env files.
  59629. */
  59630. export class EnvironmentTextureTools {
  59631. /**
  59632. * Magic number identifying the env file.
  59633. */
  59634. private static _MagicBytes;
  59635. /**
  59636. * Gets the environment info from an env file.
  59637. * @param data The array buffer containing the .env bytes.
  59638. * @returns the environment file info (the json header) if successfully parsed.
  59639. */
  59640. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59641. /**
  59642. * Creates an environment texture from a loaded cube texture.
  59643. * @param texture defines the cube texture to convert in env file
  59644. * @return a promise containing the environment data if succesfull.
  59645. */
  59646. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59647. /**
  59648. * Creates a JSON representation of the spherical data.
  59649. * @param texture defines the texture containing the polynomials
  59650. * @return the JSON representation of the spherical info
  59651. */
  59652. private static _CreateEnvTextureIrradiance;
  59653. /**
  59654. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59655. * @param data the image data
  59656. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59657. * @return the views described by info providing access to the underlying buffer
  59658. */
  59659. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59660. /**
  59661. * Uploads the texture info contained in the env file to the GPU.
  59662. * @param texture defines the internal texture to upload to
  59663. * @param data defines the data to load
  59664. * @param info defines the texture info retrieved through the GetEnvInfo method
  59665. * @returns a promise
  59666. */
  59667. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59668. private static _OnImageReadyAsync;
  59669. /**
  59670. * Uploads the levels of image data to the GPU.
  59671. * @param texture defines the internal texture to upload to
  59672. * @param imageData defines the array buffer views of image data [mipmap][face]
  59673. * @returns a promise
  59674. */
  59675. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59676. /**
  59677. * Uploads spherical polynomials information to the texture.
  59678. * @param texture defines the texture we are trying to upload the information to
  59679. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59680. */
  59681. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59682. /** @hidden */
  59683. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59684. }
  59685. }
  59686. declare module BABYLON {
  59687. /**
  59688. * Container for accessors for natively-stored mesh data buffers.
  59689. */
  59690. class NativeDataBuffer extends DataBuffer {
  59691. /**
  59692. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59693. */
  59694. nativeIndexBuffer?: any;
  59695. /**
  59696. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59697. */
  59698. nativeVertexBuffer?: any;
  59699. }
  59700. /** @hidden */
  59701. class NativeTexture extends InternalTexture {
  59702. getInternalTexture(): InternalTexture;
  59703. getViewCount(): number;
  59704. }
  59705. /** @hidden */
  59706. export class NativeEngine extends Engine {
  59707. private readonly _native;
  59708. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  59709. private readonly INVALID_HANDLE;
  59710. private _boundBuffersVertexArray;
  59711. private _currentDepthTest;
  59712. getHardwareScalingLevel(): number;
  59713. constructor();
  59714. dispose(): void;
  59715. /**
  59716. * Can be used to override the current requestAnimationFrame requester.
  59717. * @hidden
  59718. */
  59719. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  59720. /**
  59721. * Override default engine behavior.
  59722. * @param color
  59723. * @param backBuffer
  59724. * @param depth
  59725. * @param stencil
  59726. */
  59727. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  59728. /**
  59729. * Gets host document
  59730. * @returns the host document object
  59731. */
  59732. getHostDocument(): Nullable<Document>;
  59733. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59734. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  59735. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  59736. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  59737. [key: string]: VertexBuffer;
  59738. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59739. bindBuffers(vertexBuffers: {
  59740. [key: string]: VertexBuffer;
  59741. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59742. recordVertexArrayObject(vertexBuffers: {
  59743. [key: string]: VertexBuffer;
  59744. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  59745. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59746. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59747. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59748. /**
  59749. * Draw a list of indexed primitives
  59750. * @param fillMode defines the primitive to use
  59751. * @param indexStart defines the starting index
  59752. * @param indexCount defines the number of index to draw
  59753. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59754. */
  59755. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59756. /**
  59757. * Draw a list of unindexed primitives
  59758. * @param fillMode defines the primitive to use
  59759. * @param verticesStart defines the index of first vertex to draw
  59760. * @param verticesCount defines the count of vertices to draw
  59761. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59762. */
  59763. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59764. createPipelineContext(): IPipelineContext;
  59765. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  59766. /** @hidden */
  59767. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  59768. /** @hidden */
  59769. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  59770. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59771. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59772. protected _setProgram(program: WebGLProgram): void;
  59773. _releaseEffect(effect: Effect): void;
  59774. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  59775. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  59776. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  59777. bindSamplers(effect: Effect): void;
  59778. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  59779. getRenderWidth(useScreen?: boolean): number;
  59780. getRenderHeight(useScreen?: boolean): number;
  59781. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59782. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59783. /**
  59784. * Set the z offset to apply to current rendering
  59785. * @param value defines the offset to apply
  59786. */
  59787. setZOffset(value: number): void;
  59788. /**
  59789. * Gets the current value of the zOffset
  59790. * @returns the current zOffset state
  59791. */
  59792. getZOffset(): number;
  59793. /**
  59794. * Enable or disable depth buffering
  59795. * @param enable defines the state to set
  59796. */
  59797. setDepthBuffer(enable: boolean): void;
  59798. /**
  59799. * Gets a boolean indicating if depth writing is enabled
  59800. * @returns the current depth writing state
  59801. */
  59802. getDepthWrite(): boolean;
  59803. setDepthFunctionToGreater(): void;
  59804. setDepthFunctionToGreaterOrEqual(): void;
  59805. setDepthFunctionToLess(): void;
  59806. setDepthFunctionToLessOrEqual(): void;
  59807. /**
  59808. * Enable or disable depth writing
  59809. * @param enable defines the state to set
  59810. */
  59811. setDepthWrite(enable: boolean): void;
  59812. /**
  59813. * Enable or disable color writing
  59814. * @param enable defines the state to set
  59815. */
  59816. setColorWrite(enable: boolean): void;
  59817. /**
  59818. * Gets a boolean indicating if color writing is enabled
  59819. * @returns the current color writing state
  59820. */
  59821. getColorWrite(): boolean;
  59822. /**
  59823. * Sets alpha constants used by some alpha blending modes
  59824. * @param r defines the red component
  59825. * @param g defines the green component
  59826. * @param b defines the blue component
  59827. * @param a defines the alpha component
  59828. */
  59829. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  59830. /**
  59831. * Sets the current alpha mode
  59832. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  59833. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59834. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59835. */
  59836. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59837. /**
  59838. * Gets the current alpha mode
  59839. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59840. * @returns the current alpha mode
  59841. */
  59842. getAlphaMode(): number;
  59843. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  59844. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59845. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59846. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59847. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59848. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59849. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59850. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59851. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59852. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59853. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59854. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59855. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59856. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59857. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59858. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59859. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59860. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59861. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59862. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59863. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  59864. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  59865. wipeCaches(bruteForce?: boolean): void;
  59866. protected _createTexture(): WebGLTexture;
  59867. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  59868. /**
  59869. * Update the content of a dynamic texture
  59870. * @param texture defines the texture to update
  59871. * @param canvas defines the canvas containing the source
  59872. * @param invertY defines if data must be stored with Y axis inverted
  59873. * @param premulAlpha defines if alpha is stored as premultiplied
  59874. * @param format defines the format of the data
  59875. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59876. */
  59877. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59878. /**
  59879. * Usually called from Texture.ts.
  59880. * Passed information to create a WebGLTexture
  59881. * @param url defines a value which contains one of the following:
  59882. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59883. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59884. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59885. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59886. * @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)
  59887. * @param scene needed for loading to the correct scene
  59888. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59889. * @param onLoad optional callback to be called upon successful completion
  59890. * @param onError optional callback to be called upon failure
  59891. * @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
  59892. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59893. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59894. * @param forcedExtension defines the extension to use to pick the right loader
  59895. * @param mimeType defines an optional mime type
  59896. * @param loaderOptions options to be passed to the loader
  59897. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59898. */
  59899. 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;
  59900. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  59901. _releaseFramebufferObjects(texture: InternalTexture): void;
  59902. /**
  59903. * Creates a cube texture
  59904. * @param rootUrl defines the url where the files to load is located
  59905. * @param scene defines the current scene
  59906. * @param files defines the list of files to load (1 per face)
  59907. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  59908. * @param onLoad defines an optional callback raised when the texture is loaded
  59909. * @param onError defines an optional callback raised if there is an issue to load the texture
  59910. * @param format defines the format of the data
  59911. * @param forcedExtension defines the extension to use to pick the right loader
  59912. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  59913. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59914. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59915. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  59916. * @returns the cube texture as an InternalTexture
  59917. */
  59918. 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;
  59919. createRenderTargetTexture(size: number | {
  59920. width: number;
  59921. height: number;
  59922. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  59923. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59924. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59925. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59926. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  59927. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  59928. /**
  59929. * Updates a dynamic vertex buffer.
  59930. * @param vertexBuffer the vertex buffer to update
  59931. * @param data the data used to update the vertex buffer
  59932. * @param byteOffset the byte offset of the data (optional)
  59933. * @param byteLength the byte length of the data (optional)
  59934. */
  59935. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  59936. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  59937. private _updateAnisotropicLevel;
  59938. private _getAddressMode;
  59939. /** @hidden */
  59940. _bindTexture(channel: number, texture: InternalTexture): void;
  59941. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  59942. releaseEffects(): void;
  59943. /** @hidden */
  59944. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59945. /** @hidden */
  59946. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59947. /** @hidden */
  59948. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59949. /** @hidden */
  59950. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59951. private _getNativeSamplingMode;
  59952. private _getNativeTextureFormat;
  59953. private _getNativeAlphaMode;
  59954. private _getNativeAttribType;
  59955. }
  59956. }
  59957. declare module BABYLON {
  59958. /**
  59959. * Helper class to create the best engine depending on the current hardware
  59960. */
  59961. export class EngineFactory {
  59962. /**
  59963. * Creates an engine based on the capabilities of the underlying hardware
  59964. * @param canvas Defines the canvas to use to display the result
  59965. * @param options Defines the options passed to the engine to create the context dependencies
  59966. * @returns a promise that resolves with the created engine
  59967. */
  59968. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  59969. }
  59970. }
  59971. declare module BABYLON {
  59972. /**
  59973. * Gather the list of clipboard event types as constants.
  59974. */
  59975. export class ClipboardEventTypes {
  59976. /**
  59977. * The clipboard event is fired when a copy command is active (pressed).
  59978. */
  59979. static readonly COPY: number;
  59980. /**
  59981. * The clipboard event is fired when a cut command is active (pressed).
  59982. */
  59983. static readonly CUT: number;
  59984. /**
  59985. * The clipboard event is fired when a paste command is active (pressed).
  59986. */
  59987. static readonly PASTE: number;
  59988. }
  59989. /**
  59990. * This class is used to store clipboard related info for the onClipboardObservable event.
  59991. */
  59992. export class ClipboardInfo {
  59993. /**
  59994. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59995. */
  59996. type: number;
  59997. /**
  59998. * Defines the related dom event
  59999. */
  60000. event: ClipboardEvent;
  60001. /**
  60002. *Creates an instance of ClipboardInfo.
  60003. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  60004. * @param event Defines the related dom event
  60005. */
  60006. constructor(
  60007. /**
  60008. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60009. */
  60010. type: number,
  60011. /**
  60012. * Defines the related dom event
  60013. */
  60014. event: ClipboardEvent);
  60015. /**
  60016. * Get the clipboard event's type from the keycode.
  60017. * @param keyCode Defines the keyCode for the current keyboard event.
  60018. * @return {number}
  60019. */
  60020. static GetTypeFromCharacter(keyCode: number): number;
  60021. }
  60022. }
  60023. declare module BABYLON {
  60024. /**
  60025. * Google Daydream controller
  60026. */
  60027. export class DaydreamController extends WebVRController {
  60028. /**
  60029. * Base Url for the controller model.
  60030. */
  60031. static MODEL_BASE_URL: string;
  60032. /**
  60033. * File name for the controller model.
  60034. */
  60035. static MODEL_FILENAME: string;
  60036. /**
  60037. * Gamepad Id prefix used to identify Daydream Controller.
  60038. */
  60039. static readonly GAMEPAD_ID_PREFIX: string;
  60040. /**
  60041. * Creates a new DaydreamController from a gamepad
  60042. * @param vrGamepad the gamepad that the controller should be created from
  60043. */
  60044. constructor(vrGamepad: any);
  60045. /**
  60046. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60047. * @param scene scene in which to add meshes
  60048. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60049. */
  60050. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60051. /**
  60052. * Called once for each button that changed state since the last frame
  60053. * @param buttonIdx Which button index changed
  60054. * @param state New state of the button
  60055. * @param changes Which properties on the state changed since last frame
  60056. */
  60057. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60058. }
  60059. }
  60060. declare module BABYLON {
  60061. /**
  60062. * Gear VR Controller
  60063. */
  60064. export class GearVRController extends WebVRController {
  60065. /**
  60066. * Base Url for the controller model.
  60067. */
  60068. static MODEL_BASE_URL: string;
  60069. /**
  60070. * File name for the controller model.
  60071. */
  60072. static MODEL_FILENAME: string;
  60073. /**
  60074. * Gamepad Id prefix used to identify this controller.
  60075. */
  60076. static readonly GAMEPAD_ID_PREFIX: string;
  60077. private readonly _buttonIndexToObservableNameMap;
  60078. /**
  60079. * Creates a new GearVRController from a gamepad
  60080. * @param vrGamepad the gamepad that the controller should be created from
  60081. */
  60082. constructor(vrGamepad: any);
  60083. /**
  60084. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60085. * @param scene scene in which to add meshes
  60086. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60087. */
  60088. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60089. /**
  60090. * Called once for each button that changed state since the last frame
  60091. * @param buttonIdx Which button index changed
  60092. * @param state New state of the button
  60093. * @param changes Which properties on the state changed since last frame
  60094. */
  60095. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60096. }
  60097. }
  60098. declare module BABYLON {
  60099. /**
  60100. * Generic Controller
  60101. */
  60102. export class GenericController extends WebVRController {
  60103. /**
  60104. * Base Url for the controller model.
  60105. */
  60106. static readonly MODEL_BASE_URL: string;
  60107. /**
  60108. * File name for the controller model.
  60109. */
  60110. static readonly MODEL_FILENAME: string;
  60111. /**
  60112. * Creates a new GenericController from a gamepad
  60113. * @param vrGamepad the gamepad that the controller should be created from
  60114. */
  60115. constructor(vrGamepad: any);
  60116. /**
  60117. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60118. * @param scene scene in which to add meshes
  60119. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60120. */
  60121. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60122. /**
  60123. * Called once for each button that changed state since the last frame
  60124. * @param buttonIdx Which button index changed
  60125. * @param state New state of the button
  60126. * @param changes Which properties on the state changed since last frame
  60127. */
  60128. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60129. }
  60130. }
  60131. declare module BABYLON {
  60132. /**
  60133. * Oculus Touch Controller
  60134. */
  60135. export class OculusTouchController extends WebVRController {
  60136. /**
  60137. * Base Url for the controller model.
  60138. */
  60139. static MODEL_BASE_URL: string;
  60140. /**
  60141. * File name for the left controller model.
  60142. */
  60143. static MODEL_LEFT_FILENAME: string;
  60144. /**
  60145. * File name for the right controller model.
  60146. */
  60147. static MODEL_RIGHT_FILENAME: string;
  60148. /**
  60149. * Base Url for the Quest controller model.
  60150. */
  60151. static QUEST_MODEL_BASE_URL: string;
  60152. /**
  60153. * @hidden
  60154. * If the controllers are running on a device that needs the updated Quest controller models
  60155. */
  60156. static _IsQuest: boolean;
  60157. /**
  60158. * Fired when the secondary trigger on this controller is modified
  60159. */
  60160. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60161. /**
  60162. * Fired when the thumb rest on this controller is modified
  60163. */
  60164. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60165. /**
  60166. * Creates a new OculusTouchController from a gamepad
  60167. * @param vrGamepad the gamepad that the controller should be created from
  60168. */
  60169. constructor(vrGamepad: any);
  60170. /**
  60171. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60172. * @param scene scene in which to add meshes
  60173. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60174. */
  60175. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60176. /**
  60177. * Fired when the A button on this controller is modified
  60178. */
  60179. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60180. /**
  60181. * Fired when the B button on this controller is modified
  60182. */
  60183. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60184. /**
  60185. * Fired when the X button on this controller is modified
  60186. */
  60187. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60188. /**
  60189. * Fired when the Y button on this controller is modified
  60190. */
  60191. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60192. /**
  60193. * Called once for each button that changed state since the last frame
  60194. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60195. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60196. * 2) secondary trigger (same)
  60197. * 3) A (right) X (left), touch, pressed = value
  60198. * 4) B / Y
  60199. * 5) thumb rest
  60200. * @param buttonIdx Which button index changed
  60201. * @param state New state of the button
  60202. * @param changes Which properties on the state changed since last frame
  60203. */
  60204. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60205. }
  60206. }
  60207. declare module BABYLON {
  60208. /**
  60209. * Vive Controller
  60210. */
  60211. export class ViveController extends WebVRController {
  60212. /**
  60213. * Base Url for the controller model.
  60214. */
  60215. static MODEL_BASE_URL: string;
  60216. /**
  60217. * File name for the controller model.
  60218. */
  60219. static MODEL_FILENAME: string;
  60220. /**
  60221. * Creates a new ViveController from a gamepad
  60222. * @param vrGamepad the gamepad that the controller should be created from
  60223. */
  60224. constructor(vrGamepad: any);
  60225. /**
  60226. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60227. * @param scene scene in which to add meshes
  60228. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60229. */
  60230. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60231. /**
  60232. * Fired when the left button on this controller is modified
  60233. */
  60234. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60235. /**
  60236. * Fired when the right button on this controller is modified
  60237. */
  60238. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60239. /**
  60240. * Fired when the menu button on this controller is modified
  60241. */
  60242. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60243. /**
  60244. * Called once for each button that changed state since the last frame
  60245. * Vive mapping:
  60246. * 0: touchpad
  60247. * 1: trigger
  60248. * 2: left AND right buttons
  60249. * 3: menu button
  60250. * @param buttonIdx Which button index changed
  60251. * @param state New state of the button
  60252. * @param changes Which properties on the state changed since last frame
  60253. */
  60254. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60255. }
  60256. }
  60257. declare module BABYLON {
  60258. /**
  60259. * Defines the WindowsMotionController object that the state of the windows motion controller
  60260. */
  60261. export class WindowsMotionController extends WebVRController {
  60262. /**
  60263. * The base url used to load the left and right controller models
  60264. */
  60265. static MODEL_BASE_URL: string;
  60266. /**
  60267. * The name of the left controller model file
  60268. */
  60269. static MODEL_LEFT_FILENAME: string;
  60270. /**
  60271. * The name of the right controller model file
  60272. */
  60273. static MODEL_RIGHT_FILENAME: string;
  60274. /**
  60275. * The controller name prefix for this controller type
  60276. */
  60277. static readonly GAMEPAD_ID_PREFIX: string;
  60278. /**
  60279. * The controller id pattern for this controller type
  60280. */
  60281. private static readonly GAMEPAD_ID_PATTERN;
  60282. private _loadedMeshInfo;
  60283. protected readonly _mapping: {
  60284. buttons: string[];
  60285. buttonMeshNames: {
  60286. trigger: string;
  60287. menu: string;
  60288. grip: string;
  60289. thumbstick: string;
  60290. trackpad: string;
  60291. };
  60292. buttonObservableNames: {
  60293. trigger: string;
  60294. menu: string;
  60295. grip: string;
  60296. thumbstick: string;
  60297. trackpad: string;
  60298. };
  60299. axisMeshNames: string[];
  60300. pointingPoseMeshName: string;
  60301. };
  60302. /**
  60303. * Fired when the trackpad on this controller is clicked
  60304. */
  60305. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60306. /**
  60307. * Fired when the trackpad on this controller is modified
  60308. */
  60309. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60310. /**
  60311. * The current x and y values of this controller's trackpad
  60312. */
  60313. trackpad: StickValues;
  60314. /**
  60315. * Creates a new WindowsMotionController from a gamepad
  60316. * @param vrGamepad the gamepad that the controller should be created from
  60317. */
  60318. constructor(vrGamepad: any);
  60319. /**
  60320. * Fired when the trigger on this controller is modified
  60321. */
  60322. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60323. /**
  60324. * Fired when the menu button on this controller is modified
  60325. */
  60326. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60327. /**
  60328. * Fired when the grip button on this controller is modified
  60329. */
  60330. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60331. /**
  60332. * Fired when the thumbstick button on this controller is modified
  60333. */
  60334. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60335. /**
  60336. * Fired when the touchpad button on this controller is modified
  60337. */
  60338. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60339. /**
  60340. * Fired when the touchpad values on this controller are modified
  60341. */
  60342. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60343. protected _updateTrackpad(): void;
  60344. /**
  60345. * Called once per frame by the engine.
  60346. */
  60347. update(): void;
  60348. /**
  60349. * Called once for each button that changed state since the last frame
  60350. * @param buttonIdx Which button index changed
  60351. * @param state New state of the button
  60352. * @param changes Which properties on the state changed since last frame
  60353. */
  60354. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60355. /**
  60356. * Moves the buttons on the controller mesh based on their current state
  60357. * @param buttonName the name of the button to move
  60358. * @param buttonValue the value of the button which determines the buttons new position
  60359. */
  60360. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60361. /**
  60362. * Moves the axis on the controller mesh based on its current state
  60363. * @param axis the index of the axis
  60364. * @param axisValue the value of the axis which determines the meshes new position
  60365. * @hidden
  60366. */
  60367. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60368. /**
  60369. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60370. * @param scene scene in which to add meshes
  60371. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60372. */
  60373. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60374. /**
  60375. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60376. * can be transformed by button presses and axes values, based on this._mapping.
  60377. *
  60378. * @param scene scene in which the meshes exist
  60379. * @param meshes list of meshes that make up the controller model to process
  60380. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60381. */
  60382. private processModel;
  60383. private createMeshInfo;
  60384. /**
  60385. * Gets the ray of the controller in the direction the controller is pointing
  60386. * @param length the length the resulting ray should be
  60387. * @returns a ray in the direction the controller is pointing
  60388. */
  60389. getForwardRay(length?: number): Ray;
  60390. /**
  60391. * Disposes of the controller
  60392. */
  60393. dispose(): void;
  60394. }
  60395. /**
  60396. * This class represents a new windows motion controller in XR.
  60397. */
  60398. export class XRWindowsMotionController extends WindowsMotionController {
  60399. /**
  60400. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60401. */
  60402. protected readonly _mapping: {
  60403. buttons: string[];
  60404. buttonMeshNames: {
  60405. trigger: string;
  60406. menu: string;
  60407. grip: string;
  60408. thumbstick: string;
  60409. trackpad: string;
  60410. };
  60411. buttonObservableNames: {
  60412. trigger: string;
  60413. menu: string;
  60414. grip: string;
  60415. thumbstick: string;
  60416. trackpad: string;
  60417. };
  60418. axisMeshNames: string[];
  60419. pointingPoseMeshName: string;
  60420. };
  60421. /**
  60422. * Construct a new XR-Based windows motion controller
  60423. *
  60424. * @param gamepadInfo the gamepad object from the browser
  60425. */
  60426. constructor(gamepadInfo: any);
  60427. /**
  60428. * holds the thumbstick values (X,Y)
  60429. */
  60430. thumbstickValues: StickValues;
  60431. /**
  60432. * Fired when the thumbstick on this controller is clicked
  60433. */
  60434. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60435. /**
  60436. * Fired when the thumbstick on this controller is modified
  60437. */
  60438. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60439. /**
  60440. * Fired when the touchpad button on this controller is modified
  60441. */
  60442. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60443. /**
  60444. * Fired when the touchpad values on this controller are modified
  60445. */
  60446. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60447. /**
  60448. * Fired when the thumbstick button on this controller is modified
  60449. * here to prevent breaking changes
  60450. */
  60451. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60452. /**
  60453. * updating the thumbstick(!) and not the trackpad.
  60454. * This is named this way due to the difference between WebVR and XR and to avoid
  60455. * changing the parent class.
  60456. */
  60457. protected _updateTrackpad(): void;
  60458. /**
  60459. * Disposes the class with joy
  60460. */
  60461. dispose(): void;
  60462. }
  60463. }
  60464. declare module BABYLON {
  60465. /**
  60466. * A directional light is defined by a direction (what a surprise!).
  60467. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60468. * 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.
  60469. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60470. */
  60471. export class DirectionalLight extends ShadowLight {
  60472. private _shadowFrustumSize;
  60473. /**
  60474. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60475. */
  60476. get shadowFrustumSize(): number;
  60477. /**
  60478. * Specifies a fix frustum size for the shadow generation.
  60479. */
  60480. set shadowFrustumSize(value: number);
  60481. private _shadowOrthoScale;
  60482. /**
  60483. * Gets the shadow projection scale against the optimal computed one.
  60484. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60485. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60486. */
  60487. get shadowOrthoScale(): number;
  60488. /**
  60489. * Sets the shadow projection scale against the optimal computed one.
  60490. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60491. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60492. */
  60493. set shadowOrthoScale(value: number);
  60494. /**
  60495. * Automatically compute the projection matrix to best fit (including all the casters)
  60496. * on each frame.
  60497. */
  60498. autoUpdateExtends: boolean;
  60499. /**
  60500. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60501. * on each frame. autoUpdateExtends must be set to true for this to work
  60502. */
  60503. autoCalcShadowZBounds: boolean;
  60504. private _orthoLeft;
  60505. private _orthoRight;
  60506. private _orthoTop;
  60507. private _orthoBottom;
  60508. /**
  60509. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60510. * The directional light is emitted from everywhere in the given direction.
  60511. * It can cast shadows.
  60512. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60513. * @param name The friendly name of the light
  60514. * @param direction The direction of the light
  60515. * @param scene The scene the light belongs to
  60516. */
  60517. constructor(name: string, direction: Vector3, scene: Scene);
  60518. /**
  60519. * Returns the string "DirectionalLight".
  60520. * @return The class name
  60521. */
  60522. getClassName(): string;
  60523. /**
  60524. * Returns the integer 1.
  60525. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60526. */
  60527. getTypeID(): number;
  60528. /**
  60529. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60530. * Returns the DirectionalLight Shadow projection matrix.
  60531. */
  60532. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60533. /**
  60534. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60535. * Returns the DirectionalLight Shadow projection matrix.
  60536. */
  60537. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60538. /**
  60539. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60540. * Returns the DirectionalLight Shadow projection matrix.
  60541. */
  60542. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60543. protected _buildUniformLayout(): void;
  60544. /**
  60545. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60546. * @param effect The effect to update
  60547. * @param lightIndex The index of the light in the effect to update
  60548. * @returns The directional light
  60549. */
  60550. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60551. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60552. /**
  60553. * Gets the minZ used for shadow according to both the scene and the light.
  60554. *
  60555. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60556. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60557. * @param activeCamera The camera we are returning the min for
  60558. * @returns the depth min z
  60559. */
  60560. getDepthMinZ(activeCamera: Camera): number;
  60561. /**
  60562. * Gets the maxZ used for shadow according to both the scene and the light.
  60563. *
  60564. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60565. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60566. * @param activeCamera The camera we are returning the max for
  60567. * @returns the depth max z
  60568. */
  60569. getDepthMaxZ(activeCamera: Camera): number;
  60570. /**
  60571. * Prepares the list of defines specific to the light type.
  60572. * @param defines the list of defines
  60573. * @param lightIndex defines the index of the light for the effect
  60574. */
  60575. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60576. }
  60577. }
  60578. declare module BABYLON {
  60579. /**
  60580. * Class containing static functions to help procedurally build meshes
  60581. */
  60582. export class HemisphereBuilder {
  60583. /**
  60584. * Creates a hemisphere mesh
  60585. * @param name defines the name of the mesh
  60586. * @param options defines the options used to create the mesh
  60587. * @param scene defines the hosting scene
  60588. * @returns the hemisphere mesh
  60589. */
  60590. static CreateHemisphere(name: string, options: {
  60591. segments?: number;
  60592. diameter?: number;
  60593. sideOrientation?: number;
  60594. }, scene: any): Mesh;
  60595. }
  60596. }
  60597. declare module BABYLON {
  60598. /**
  60599. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60600. * These values define a cone of light starting from the position, emitting toward the direction.
  60601. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60602. * and the exponent defines the speed of the decay of the light with distance (reach).
  60603. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60604. */
  60605. export class SpotLight extends ShadowLight {
  60606. private _angle;
  60607. private _innerAngle;
  60608. private _cosHalfAngle;
  60609. private _lightAngleScale;
  60610. private _lightAngleOffset;
  60611. /**
  60612. * Gets the cone angle of the spot light in Radians.
  60613. */
  60614. get angle(): number;
  60615. /**
  60616. * Sets the cone angle of the spot light in Radians.
  60617. */
  60618. set angle(value: number);
  60619. /**
  60620. * Only used in gltf falloff mode, this defines the angle where
  60621. * the directional falloff will start before cutting at angle which could be seen
  60622. * as outer angle.
  60623. */
  60624. get innerAngle(): number;
  60625. /**
  60626. * Only used in gltf falloff mode, this defines the angle where
  60627. * the directional falloff will start before cutting at angle which could be seen
  60628. * as outer angle.
  60629. */
  60630. set innerAngle(value: number);
  60631. private _shadowAngleScale;
  60632. /**
  60633. * Allows scaling the angle of the light for shadow generation only.
  60634. */
  60635. get shadowAngleScale(): number;
  60636. /**
  60637. * Allows scaling the angle of the light for shadow generation only.
  60638. */
  60639. set shadowAngleScale(value: number);
  60640. /**
  60641. * The light decay speed with the distance from the emission spot.
  60642. */
  60643. exponent: number;
  60644. private _projectionTextureMatrix;
  60645. /**
  60646. * Allows reading the projecton texture
  60647. */
  60648. get projectionTextureMatrix(): Matrix;
  60649. protected _projectionTextureLightNear: number;
  60650. /**
  60651. * Gets the near clip of the Spotlight for texture projection.
  60652. */
  60653. get projectionTextureLightNear(): number;
  60654. /**
  60655. * Sets the near clip of the Spotlight for texture projection.
  60656. */
  60657. set projectionTextureLightNear(value: number);
  60658. protected _projectionTextureLightFar: number;
  60659. /**
  60660. * Gets the far clip of the Spotlight for texture projection.
  60661. */
  60662. get projectionTextureLightFar(): number;
  60663. /**
  60664. * Sets the far clip of the Spotlight for texture projection.
  60665. */
  60666. set projectionTextureLightFar(value: number);
  60667. protected _projectionTextureUpDirection: Vector3;
  60668. /**
  60669. * Gets the Up vector of the Spotlight for texture projection.
  60670. */
  60671. get projectionTextureUpDirection(): Vector3;
  60672. /**
  60673. * Sets the Up vector of the Spotlight for texture projection.
  60674. */
  60675. set projectionTextureUpDirection(value: Vector3);
  60676. private _projectionTexture;
  60677. /**
  60678. * Gets the projection texture of the light.
  60679. */
  60680. get projectionTexture(): Nullable<BaseTexture>;
  60681. /**
  60682. * Sets the projection texture of the light.
  60683. */
  60684. set projectionTexture(value: Nullable<BaseTexture>);
  60685. private static _IsProceduralTexture;
  60686. private static _IsTexture;
  60687. private _projectionTextureViewLightDirty;
  60688. private _projectionTextureProjectionLightDirty;
  60689. private _projectionTextureDirty;
  60690. private _projectionTextureViewTargetVector;
  60691. private _projectionTextureViewLightMatrix;
  60692. private _projectionTextureProjectionLightMatrix;
  60693. private _projectionTextureScalingMatrix;
  60694. /**
  60695. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60696. * It can cast shadows.
  60697. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60698. * @param name The light friendly name
  60699. * @param position The position of the spot light in the scene
  60700. * @param direction The direction of the light in the scene
  60701. * @param angle The cone angle of the light in Radians
  60702. * @param exponent The light decay speed with the distance from the emission spot
  60703. * @param scene The scene the lights belongs to
  60704. */
  60705. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60706. /**
  60707. * Returns the string "SpotLight".
  60708. * @returns the class name
  60709. */
  60710. getClassName(): string;
  60711. /**
  60712. * Returns the integer 2.
  60713. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60714. */
  60715. getTypeID(): number;
  60716. /**
  60717. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60718. */
  60719. protected _setDirection(value: Vector3): void;
  60720. /**
  60721. * Overrides the position setter to recompute the projection texture view light Matrix.
  60722. */
  60723. protected _setPosition(value: Vector3): void;
  60724. /**
  60725. * 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.
  60726. * Returns the SpotLight.
  60727. */
  60728. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60729. protected _computeProjectionTextureViewLightMatrix(): void;
  60730. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60731. /**
  60732. * Main function for light texture projection matrix computing.
  60733. */
  60734. protected _computeProjectionTextureMatrix(): void;
  60735. protected _buildUniformLayout(): void;
  60736. private _computeAngleValues;
  60737. /**
  60738. * Sets the passed Effect "effect" with the Light textures.
  60739. * @param effect The effect to update
  60740. * @param lightIndex The index of the light in the effect to update
  60741. * @returns The light
  60742. */
  60743. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60744. /**
  60745. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60746. * @param effect The effect to update
  60747. * @param lightIndex The index of the light in the effect to update
  60748. * @returns The spot light
  60749. */
  60750. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60751. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60752. /**
  60753. * Disposes the light and the associated resources.
  60754. */
  60755. dispose(): void;
  60756. /**
  60757. * Prepares the list of defines specific to the light type.
  60758. * @param defines the list of defines
  60759. * @param lightIndex defines the index of the light for the effect
  60760. */
  60761. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60762. }
  60763. }
  60764. declare module BABYLON {
  60765. /**
  60766. * Gizmo that enables viewing a light
  60767. */
  60768. export class LightGizmo extends Gizmo {
  60769. private _lightMesh;
  60770. private _material;
  60771. private _cachedPosition;
  60772. private _cachedForward;
  60773. private _attachedMeshParent;
  60774. private _pointerObserver;
  60775. /**
  60776. * Event that fires each time the gizmo is clicked
  60777. */
  60778. onClickedObservable: Observable<Light>;
  60779. /**
  60780. * Creates a LightGizmo
  60781. * @param gizmoLayer The utility layer the gizmo will be added to
  60782. */
  60783. constructor(gizmoLayer?: UtilityLayerRenderer);
  60784. private _light;
  60785. /**
  60786. * The light that the gizmo is attached to
  60787. */
  60788. set light(light: Nullable<Light>);
  60789. get light(): Nullable<Light>;
  60790. /**
  60791. * Gets the material used to render the light gizmo
  60792. */
  60793. get material(): StandardMaterial;
  60794. /**
  60795. * @hidden
  60796. * Updates the gizmo to match the attached mesh's position/rotation
  60797. */
  60798. protected _update(): void;
  60799. private static _Scale;
  60800. /**
  60801. * Creates the lines for a light mesh
  60802. */
  60803. private static _CreateLightLines;
  60804. /**
  60805. * Disposes of the light gizmo
  60806. */
  60807. dispose(): void;
  60808. private static _CreateHemisphericLightMesh;
  60809. private static _CreatePointLightMesh;
  60810. private static _CreateSpotLightMesh;
  60811. private static _CreateDirectionalLightMesh;
  60812. }
  60813. }
  60814. declare module BABYLON {
  60815. /**
  60816. * Gizmo that enables viewing a camera
  60817. */
  60818. export class CameraGizmo extends Gizmo {
  60819. private _cameraMesh;
  60820. private _cameraLinesMesh;
  60821. private _material;
  60822. private _pointerObserver;
  60823. /**
  60824. * Event that fires each time the gizmo is clicked
  60825. */
  60826. onClickedObservable: Observable<Camera>;
  60827. /**
  60828. * Creates a CameraGizmo
  60829. * @param gizmoLayer The utility layer the gizmo will be added to
  60830. */
  60831. constructor(gizmoLayer?: UtilityLayerRenderer);
  60832. private _camera;
  60833. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  60834. get displayFrustum(): boolean;
  60835. set displayFrustum(value: boolean);
  60836. /**
  60837. * The camera that the gizmo is attached to
  60838. */
  60839. set camera(camera: Nullable<Camera>);
  60840. get camera(): Nullable<Camera>;
  60841. /**
  60842. * Gets the material used to render the camera gizmo
  60843. */
  60844. get material(): StandardMaterial;
  60845. /**
  60846. * @hidden
  60847. * Updates the gizmo to match the attached mesh's position/rotation
  60848. */
  60849. protected _update(): void;
  60850. private static _Scale;
  60851. private _invProjection;
  60852. /**
  60853. * Disposes of the camera gizmo
  60854. */
  60855. dispose(): void;
  60856. private static _CreateCameraMesh;
  60857. private static _CreateCameraFrustum;
  60858. }
  60859. }
  60860. declare module BABYLON {
  60861. /** @hidden */
  60862. export var backgroundFragmentDeclaration: {
  60863. name: string;
  60864. shader: string;
  60865. };
  60866. }
  60867. declare module BABYLON {
  60868. /** @hidden */
  60869. export var backgroundUboDeclaration: {
  60870. name: string;
  60871. shader: string;
  60872. };
  60873. }
  60874. declare module BABYLON {
  60875. /** @hidden */
  60876. export var backgroundPixelShader: {
  60877. name: string;
  60878. shader: string;
  60879. };
  60880. }
  60881. declare module BABYLON {
  60882. /** @hidden */
  60883. export var backgroundVertexDeclaration: {
  60884. name: string;
  60885. shader: string;
  60886. };
  60887. }
  60888. declare module BABYLON {
  60889. /** @hidden */
  60890. export var backgroundVertexShader: {
  60891. name: string;
  60892. shader: string;
  60893. };
  60894. }
  60895. declare module BABYLON {
  60896. /**
  60897. * Background material used to create an efficient environement around your scene.
  60898. */
  60899. export class BackgroundMaterial extends PushMaterial {
  60900. /**
  60901. * Standard reflectance value at parallel view angle.
  60902. */
  60903. static StandardReflectance0: number;
  60904. /**
  60905. * Standard reflectance value at grazing angle.
  60906. */
  60907. static StandardReflectance90: number;
  60908. protected _primaryColor: Color3;
  60909. /**
  60910. * Key light Color (multiply against the environement texture)
  60911. */
  60912. primaryColor: Color3;
  60913. protected __perceptualColor: Nullable<Color3>;
  60914. /**
  60915. * Experimental Internal Use Only.
  60916. *
  60917. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60918. * This acts as a helper to set the primary color to a more "human friendly" value.
  60919. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60920. * output color as close as possible from the chosen value.
  60921. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60922. * part of lighting setup.)
  60923. */
  60924. get _perceptualColor(): Nullable<Color3>;
  60925. set _perceptualColor(value: Nullable<Color3>);
  60926. protected _primaryColorShadowLevel: float;
  60927. /**
  60928. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60929. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60930. */
  60931. get primaryColorShadowLevel(): float;
  60932. set primaryColorShadowLevel(value: float);
  60933. protected _primaryColorHighlightLevel: float;
  60934. /**
  60935. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60936. * The primary color is used at the level chosen to define what the white area would look.
  60937. */
  60938. get primaryColorHighlightLevel(): float;
  60939. set primaryColorHighlightLevel(value: float);
  60940. protected _reflectionTexture: Nullable<BaseTexture>;
  60941. /**
  60942. * Reflection Texture used in the material.
  60943. * Should be author in a specific way for the best result (refer to the documentation).
  60944. */
  60945. reflectionTexture: Nullable<BaseTexture>;
  60946. protected _reflectionBlur: float;
  60947. /**
  60948. * Reflection Texture level of blur.
  60949. *
  60950. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60951. * texture twice.
  60952. */
  60953. reflectionBlur: float;
  60954. protected _diffuseTexture: Nullable<BaseTexture>;
  60955. /**
  60956. * Diffuse Texture used in the material.
  60957. * Should be author in a specific way for the best result (refer to the documentation).
  60958. */
  60959. diffuseTexture: Nullable<BaseTexture>;
  60960. protected _shadowLights: Nullable<IShadowLight[]>;
  60961. /**
  60962. * Specify the list of lights casting shadow on the material.
  60963. * All scene shadow lights will be included if null.
  60964. */
  60965. shadowLights: Nullable<IShadowLight[]>;
  60966. protected _shadowLevel: float;
  60967. /**
  60968. * Helps adjusting the shadow to a softer level if required.
  60969. * 0 means black shadows and 1 means no shadows.
  60970. */
  60971. shadowLevel: float;
  60972. protected _sceneCenter: Vector3;
  60973. /**
  60974. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60975. * It is usually zero but might be interesting to modify according to your setup.
  60976. */
  60977. sceneCenter: Vector3;
  60978. protected _opacityFresnel: boolean;
  60979. /**
  60980. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60981. * This helps ensuring a nice transition when the camera goes under the ground.
  60982. */
  60983. opacityFresnel: boolean;
  60984. protected _reflectionFresnel: boolean;
  60985. /**
  60986. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60987. * This helps adding a mirror texture on the ground.
  60988. */
  60989. reflectionFresnel: boolean;
  60990. protected _reflectionFalloffDistance: number;
  60991. /**
  60992. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60993. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60994. */
  60995. reflectionFalloffDistance: number;
  60996. protected _reflectionAmount: number;
  60997. /**
  60998. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60999. */
  61000. reflectionAmount: number;
  61001. protected _reflectionReflectance0: number;
  61002. /**
  61003. * This specifies the weight of the reflection at grazing angle.
  61004. */
  61005. reflectionReflectance0: number;
  61006. protected _reflectionReflectance90: number;
  61007. /**
  61008. * This specifies the weight of the reflection at a perpendicular point of view.
  61009. */
  61010. reflectionReflectance90: number;
  61011. /**
  61012. * Sets the reflection reflectance fresnel values according to the default standard
  61013. * empirically know to work well :-)
  61014. */
  61015. set reflectionStandardFresnelWeight(value: number);
  61016. protected _useRGBColor: boolean;
  61017. /**
  61018. * Helps to directly use the maps channels instead of their level.
  61019. */
  61020. useRGBColor: boolean;
  61021. protected _enableNoise: boolean;
  61022. /**
  61023. * This helps reducing the banding effect that could occur on the background.
  61024. */
  61025. enableNoise: boolean;
  61026. /**
  61027. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61028. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  61029. * Recommended to be keep at 1.0 except for special cases.
  61030. */
  61031. get fovMultiplier(): number;
  61032. set fovMultiplier(value: number);
  61033. private _fovMultiplier;
  61034. /**
  61035. * Enable the FOV adjustment feature controlled by fovMultiplier.
  61036. */
  61037. useEquirectangularFOV: boolean;
  61038. private _maxSimultaneousLights;
  61039. /**
  61040. * Number of Simultaneous lights allowed on the material.
  61041. */
  61042. maxSimultaneousLights: int;
  61043. private _shadowOnly;
  61044. /**
  61045. * Make the material only render shadows
  61046. */
  61047. shadowOnly: boolean;
  61048. /**
  61049. * Default configuration related to image processing available in the Background Material.
  61050. */
  61051. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61052. /**
  61053. * Keep track of the image processing observer to allow dispose and replace.
  61054. */
  61055. private _imageProcessingObserver;
  61056. /**
  61057. * Attaches a new image processing configuration to the PBR Material.
  61058. * @param configuration (if null the scene configuration will be use)
  61059. */
  61060. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61061. /**
  61062. * Gets the image processing configuration used either in this material.
  61063. */
  61064. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61065. /**
  61066. * Sets the Default image processing configuration used either in the this material.
  61067. *
  61068. * If sets to null, the scene one is in use.
  61069. */
  61070. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61071. /**
  61072. * Gets wether the color curves effect is enabled.
  61073. */
  61074. get cameraColorCurvesEnabled(): boolean;
  61075. /**
  61076. * Sets wether the color curves effect is enabled.
  61077. */
  61078. set cameraColorCurvesEnabled(value: boolean);
  61079. /**
  61080. * Gets wether the color grading effect is enabled.
  61081. */
  61082. get cameraColorGradingEnabled(): boolean;
  61083. /**
  61084. * Gets wether the color grading effect is enabled.
  61085. */
  61086. set cameraColorGradingEnabled(value: boolean);
  61087. /**
  61088. * Gets wether tonemapping is enabled or not.
  61089. */
  61090. get cameraToneMappingEnabled(): boolean;
  61091. /**
  61092. * Sets wether tonemapping is enabled or not
  61093. */
  61094. set cameraToneMappingEnabled(value: boolean);
  61095. /**
  61096. * The camera exposure used on this material.
  61097. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61098. * This corresponds to a photographic exposure.
  61099. */
  61100. get cameraExposure(): float;
  61101. /**
  61102. * The camera exposure used on this material.
  61103. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61104. * This corresponds to a photographic exposure.
  61105. */
  61106. set cameraExposure(value: float);
  61107. /**
  61108. * Gets The camera contrast used on this material.
  61109. */
  61110. get cameraContrast(): float;
  61111. /**
  61112. * Sets The camera contrast used on this material.
  61113. */
  61114. set cameraContrast(value: float);
  61115. /**
  61116. * Gets the Color Grading 2D Lookup Texture.
  61117. */
  61118. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61119. /**
  61120. * Sets the Color Grading 2D Lookup Texture.
  61121. */
  61122. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61123. /**
  61124. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61125. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61126. * 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;
  61127. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61128. */
  61129. get cameraColorCurves(): Nullable<ColorCurves>;
  61130. /**
  61131. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61132. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61133. * 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;
  61134. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61135. */
  61136. set cameraColorCurves(value: Nullable<ColorCurves>);
  61137. /**
  61138. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61139. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61140. */
  61141. switchToBGR: boolean;
  61142. private _renderTargets;
  61143. private _reflectionControls;
  61144. private _white;
  61145. private _primaryShadowColor;
  61146. private _primaryHighlightColor;
  61147. /**
  61148. * Instantiates a Background Material in the given scene
  61149. * @param name The friendly name of the material
  61150. * @param scene The scene to add the material to
  61151. */
  61152. constructor(name: string, scene: Scene);
  61153. /**
  61154. * Gets a boolean indicating that current material needs to register RTT
  61155. */
  61156. get hasRenderTargetTextures(): boolean;
  61157. /**
  61158. * The entire material has been created in order to prevent overdraw.
  61159. * @returns false
  61160. */
  61161. needAlphaTesting(): boolean;
  61162. /**
  61163. * The entire material has been created in order to prevent overdraw.
  61164. * @returns true if blending is enable
  61165. */
  61166. needAlphaBlending(): boolean;
  61167. /**
  61168. * Checks wether the material is ready to be rendered for a given mesh.
  61169. * @param mesh The mesh to render
  61170. * @param subMesh The submesh to check against
  61171. * @param useInstances Specify wether or not the material is used with instances
  61172. * @returns true if all the dependencies are ready (Textures, Effects...)
  61173. */
  61174. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61175. /**
  61176. * Compute the primary color according to the chosen perceptual color.
  61177. */
  61178. private _computePrimaryColorFromPerceptualColor;
  61179. /**
  61180. * Compute the highlights and shadow colors according to their chosen levels.
  61181. */
  61182. private _computePrimaryColors;
  61183. /**
  61184. * Build the uniform buffer used in the material.
  61185. */
  61186. buildUniformLayout(): void;
  61187. /**
  61188. * Unbind the material.
  61189. */
  61190. unbind(): void;
  61191. /**
  61192. * Bind only the world matrix to the material.
  61193. * @param world The world matrix to bind.
  61194. */
  61195. bindOnlyWorldMatrix(world: Matrix): void;
  61196. /**
  61197. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61198. * @param world The world matrix to bind.
  61199. * @param subMesh The submesh to bind for.
  61200. */
  61201. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61202. /**
  61203. * Checks to see if a texture is used in the material.
  61204. * @param texture - Base texture to use.
  61205. * @returns - Boolean specifying if a texture is used in the material.
  61206. */
  61207. hasTexture(texture: BaseTexture): boolean;
  61208. /**
  61209. * Dispose the material.
  61210. * @param forceDisposeEffect Force disposal of the associated effect.
  61211. * @param forceDisposeTextures Force disposal of the associated textures.
  61212. */
  61213. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61214. /**
  61215. * Clones the material.
  61216. * @param name The cloned name.
  61217. * @returns The cloned material.
  61218. */
  61219. clone(name: string): BackgroundMaterial;
  61220. /**
  61221. * Serializes the current material to its JSON representation.
  61222. * @returns The JSON representation.
  61223. */
  61224. serialize(): any;
  61225. /**
  61226. * Gets the class name of the material
  61227. * @returns "BackgroundMaterial"
  61228. */
  61229. getClassName(): string;
  61230. /**
  61231. * Parse a JSON input to create back a background material.
  61232. * @param source The JSON data to parse
  61233. * @param scene The scene to create the parsed material in
  61234. * @param rootUrl The root url of the assets the material depends upon
  61235. * @returns the instantiated BackgroundMaterial.
  61236. */
  61237. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61238. }
  61239. }
  61240. declare module BABYLON {
  61241. /**
  61242. * Represents the different options available during the creation of
  61243. * a Environment helper.
  61244. *
  61245. * This can control the default ground, skybox and image processing setup of your scene.
  61246. */
  61247. export interface IEnvironmentHelperOptions {
  61248. /**
  61249. * Specifies whether or not to create a ground.
  61250. * True by default.
  61251. */
  61252. createGround: boolean;
  61253. /**
  61254. * Specifies the ground size.
  61255. * 15 by default.
  61256. */
  61257. groundSize: number;
  61258. /**
  61259. * The texture used on the ground for the main color.
  61260. * Comes from the BabylonJS CDN by default.
  61261. *
  61262. * Remarks: Can be either a texture or a url.
  61263. */
  61264. groundTexture: string | BaseTexture;
  61265. /**
  61266. * The color mixed in the ground texture by default.
  61267. * BabylonJS clearColor by default.
  61268. */
  61269. groundColor: Color3;
  61270. /**
  61271. * Specifies the ground opacity.
  61272. * 1 by default.
  61273. */
  61274. groundOpacity: number;
  61275. /**
  61276. * Enables the ground to receive shadows.
  61277. * True by default.
  61278. */
  61279. enableGroundShadow: boolean;
  61280. /**
  61281. * Helps preventing the shadow to be fully black on the ground.
  61282. * 0.5 by default.
  61283. */
  61284. groundShadowLevel: number;
  61285. /**
  61286. * Creates a mirror texture attach to the ground.
  61287. * false by default.
  61288. */
  61289. enableGroundMirror: boolean;
  61290. /**
  61291. * Specifies the ground mirror size ratio.
  61292. * 0.3 by default as the default kernel is 64.
  61293. */
  61294. groundMirrorSizeRatio: number;
  61295. /**
  61296. * Specifies the ground mirror blur kernel size.
  61297. * 64 by default.
  61298. */
  61299. groundMirrorBlurKernel: number;
  61300. /**
  61301. * Specifies the ground mirror visibility amount.
  61302. * 1 by default
  61303. */
  61304. groundMirrorAmount: number;
  61305. /**
  61306. * Specifies the ground mirror reflectance weight.
  61307. * This uses the standard weight of the background material to setup the fresnel effect
  61308. * of the mirror.
  61309. * 1 by default.
  61310. */
  61311. groundMirrorFresnelWeight: number;
  61312. /**
  61313. * Specifies the ground mirror Falloff distance.
  61314. * This can helps reducing the size of the reflection.
  61315. * 0 by Default.
  61316. */
  61317. groundMirrorFallOffDistance: number;
  61318. /**
  61319. * Specifies the ground mirror texture type.
  61320. * Unsigned Int by Default.
  61321. */
  61322. groundMirrorTextureType: number;
  61323. /**
  61324. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61325. * the shown objects.
  61326. */
  61327. groundYBias: number;
  61328. /**
  61329. * Specifies whether or not to create a skybox.
  61330. * True by default.
  61331. */
  61332. createSkybox: boolean;
  61333. /**
  61334. * Specifies the skybox size.
  61335. * 20 by default.
  61336. */
  61337. skyboxSize: number;
  61338. /**
  61339. * The texture used on the skybox for the main color.
  61340. * Comes from the BabylonJS CDN by default.
  61341. *
  61342. * Remarks: Can be either a texture or a url.
  61343. */
  61344. skyboxTexture: string | BaseTexture;
  61345. /**
  61346. * The color mixed in the skybox texture by default.
  61347. * BabylonJS clearColor by default.
  61348. */
  61349. skyboxColor: Color3;
  61350. /**
  61351. * The background rotation around the Y axis of the scene.
  61352. * This helps aligning the key lights of your scene with the background.
  61353. * 0 by default.
  61354. */
  61355. backgroundYRotation: number;
  61356. /**
  61357. * Compute automatically the size of the elements to best fit with the scene.
  61358. */
  61359. sizeAuto: boolean;
  61360. /**
  61361. * Default position of the rootMesh if autoSize is not true.
  61362. */
  61363. rootPosition: Vector3;
  61364. /**
  61365. * Sets up the image processing in the scene.
  61366. * true by default.
  61367. */
  61368. setupImageProcessing: boolean;
  61369. /**
  61370. * The texture used as your environment texture in the scene.
  61371. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61372. *
  61373. * Remarks: Can be either a texture or a url.
  61374. */
  61375. environmentTexture: string | BaseTexture;
  61376. /**
  61377. * The value of the exposure to apply to the scene.
  61378. * 0.6 by default if setupImageProcessing is true.
  61379. */
  61380. cameraExposure: number;
  61381. /**
  61382. * The value of the contrast to apply to the scene.
  61383. * 1.6 by default if setupImageProcessing is true.
  61384. */
  61385. cameraContrast: number;
  61386. /**
  61387. * Specifies whether or not tonemapping should be enabled in the scene.
  61388. * true by default if setupImageProcessing is true.
  61389. */
  61390. toneMappingEnabled: boolean;
  61391. }
  61392. /**
  61393. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61394. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61395. * It also helps with the default setup of your imageProcessing configuration.
  61396. */
  61397. export class EnvironmentHelper {
  61398. /**
  61399. * Default ground texture URL.
  61400. */
  61401. private static _groundTextureCDNUrl;
  61402. /**
  61403. * Default skybox texture URL.
  61404. */
  61405. private static _skyboxTextureCDNUrl;
  61406. /**
  61407. * Default environment texture URL.
  61408. */
  61409. private static _environmentTextureCDNUrl;
  61410. /**
  61411. * Creates the default options for the helper.
  61412. */
  61413. private static _getDefaultOptions;
  61414. private _rootMesh;
  61415. /**
  61416. * Gets the root mesh created by the helper.
  61417. */
  61418. get rootMesh(): Mesh;
  61419. private _skybox;
  61420. /**
  61421. * Gets the skybox created by the helper.
  61422. */
  61423. get skybox(): Nullable<Mesh>;
  61424. private _skyboxTexture;
  61425. /**
  61426. * Gets the skybox texture created by the helper.
  61427. */
  61428. get skyboxTexture(): Nullable<BaseTexture>;
  61429. private _skyboxMaterial;
  61430. /**
  61431. * Gets the skybox material created by the helper.
  61432. */
  61433. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61434. private _ground;
  61435. /**
  61436. * Gets the ground mesh created by the helper.
  61437. */
  61438. get ground(): Nullable<Mesh>;
  61439. private _groundTexture;
  61440. /**
  61441. * Gets the ground texture created by the helper.
  61442. */
  61443. get groundTexture(): Nullable<BaseTexture>;
  61444. private _groundMirror;
  61445. /**
  61446. * Gets the ground mirror created by the helper.
  61447. */
  61448. get groundMirror(): Nullable<MirrorTexture>;
  61449. /**
  61450. * Gets the ground mirror render list to helps pushing the meshes
  61451. * you wish in the ground reflection.
  61452. */
  61453. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61454. private _groundMaterial;
  61455. /**
  61456. * Gets the ground material created by the helper.
  61457. */
  61458. get groundMaterial(): Nullable<BackgroundMaterial>;
  61459. /**
  61460. * Stores the creation options.
  61461. */
  61462. private readonly _scene;
  61463. private _options;
  61464. /**
  61465. * This observable will be notified with any error during the creation of the environment,
  61466. * mainly texture creation errors.
  61467. */
  61468. onErrorObservable: Observable<{
  61469. message?: string;
  61470. exception?: any;
  61471. }>;
  61472. /**
  61473. * constructor
  61474. * @param options Defines the options we want to customize the helper
  61475. * @param scene The scene to add the material to
  61476. */
  61477. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61478. /**
  61479. * Updates the background according to the new options
  61480. * @param options
  61481. */
  61482. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61483. /**
  61484. * Sets the primary color of all the available elements.
  61485. * @param color the main color to affect to the ground and the background
  61486. */
  61487. setMainColor(color: Color3): void;
  61488. /**
  61489. * Setup the image processing according to the specified options.
  61490. */
  61491. private _setupImageProcessing;
  61492. /**
  61493. * Setup the environment texture according to the specified options.
  61494. */
  61495. private _setupEnvironmentTexture;
  61496. /**
  61497. * Setup the background according to the specified options.
  61498. */
  61499. private _setupBackground;
  61500. /**
  61501. * Get the scene sizes according to the setup.
  61502. */
  61503. private _getSceneSize;
  61504. /**
  61505. * Setup the ground according to the specified options.
  61506. */
  61507. private _setupGround;
  61508. /**
  61509. * Setup the ground material according to the specified options.
  61510. */
  61511. private _setupGroundMaterial;
  61512. /**
  61513. * Setup the ground diffuse texture according to the specified options.
  61514. */
  61515. private _setupGroundDiffuseTexture;
  61516. /**
  61517. * Setup the ground mirror texture according to the specified options.
  61518. */
  61519. private _setupGroundMirrorTexture;
  61520. /**
  61521. * Setup the ground to receive the mirror texture.
  61522. */
  61523. private _setupMirrorInGroundMaterial;
  61524. /**
  61525. * Setup the skybox according to the specified options.
  61526. */
  61527. private _setupSkybox;
  61528. /**
  61529. * Setup the skybox material according to the specified options.
  61530. */
  61531. private _setupSkyboxMaterial;
  61532. /**
  61533. * Setup the skybox reflection texture according to the specified options.
  61534. */
  61535. private _setupSkyboxReflectionTexture;
  61536. private _errorHandler;
  61537. /**
  61538. * Dispose all the elements created by the Helper.
  61539. */
  61540. dispose(): void;
  61541. }
  61542. }
  61543. declare module BABYLON {
  61544. /**
  61545. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61546. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61547. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61548. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61549. */
  61550. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61551. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61552. /**
  61553. * Define the source as a Monoscopic panoramic 360/180.
  61554. */
  61555. static readonly MODE_MONOSCOPIC: number;
  61556. /**
  61557. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61558. */
  61559. static readonly MODE_TOPBOTTOM: number;
  61560. /**
  61561. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61562. */
  61563. static readonly MODE_SIDEBYSIDE: number;
  61564. private _halfDome;
  61565. private _crossEye;
  61566. protected _useDirectMapping: boolean;
  61567. /**
  61568. * The texture being displayed on the sphere
  61569. */
  61570. protected _texture: T;
  61571. /**
  61572. * Gets the texture being displayed on the sphere
  61573. */
  61574. get texture(): T;
  61575. /**
  61576. * Sets the texture being displayed on the sphere
  61577. */
  61578. set texture(newTexture: T);
  61579. /**
  61580. * The skybox material
  61581. */
  61582. protected _material: BackgroundMaterial;
  61583. /**
  61584. * The surface used for the dome
  61585. */
  61586. protected _mesh: Mesh;
  61587. /**
  61588. * Gets the mesh used for the dome.
  61589. */
  61590. get mesh(): Mesh;
  61591. /**
  61592. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61593. */
  61594. private _halfDomeMask;
  61595. /**
  61596. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61597. * Also see the options.resolution property.
  61598. */
  61599. get fovMultiplier(): number;
  61600. set fovMultiplier(value: number);
  61601. protected _textureMode: number;
  61602. /**
  61603. * Gets or set the current texture mode for the texture. It can be:
  61604. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61605. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61606. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61607. */
  61608. get textureMode(): number;
  61609. /**
  61610. * Sets the current texture mode for the texture. It can be:
  61611. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61612. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61613. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61614. */
  61615. set textureMode(value: number);
  61616. /**
  61617. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61618. */
  61619. get halfDome(): boolean;
  61620. /**
  61621. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61622. */
  61623. set halfDome(enabled: boolean);
  61624. /**
  61625. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61626. */
  61627. set crossEye(enabled: boolean);
  61628. /**
  61629. * Is it a cross-eye texture?
  61630. */
  61631. get crossEye(): boolean;
  61632. /**
  61633. * The background material of this dome.
  61634. */
  61635. get material(): BackgroundMaterial;
  61636. /**
  61637. * Oberserver used in Stereoscopic VR Mode.
  61638. */
  61639. private _onBeforeCameraRenderObserver;
  61640. /**
  61641. * Observable raised when an error occured while loading the 360 image
  61642. */
  61643. onLoadErrorObservable: Observable<string>;
  61644. /**
  61645. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61646. * @param name Element's name, child elements will append suffixes for their own names.
  61647. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61648. * @param options An object containing optional or exposed sub element properties
  61649. */
  61650. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61651. resolution?: number;
  61652. clickToPlay?: boolean;
  61653. autoPlay?: boolean;
  61654. loop?: boolean;
  61655. size?: number;
  61656. poster?: string;
  61657. faceForward?: boolean;
  61658. useDirectMapping?: boolean;
  61659. halfDomeMode?: boolean;
  61660. crossEyeMode?: boolean;
  61661. generateMipMaps?: boolean;
  61662. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61663. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61664. protected _changeTextureMode(value: number): void;
  61665. /**
  61666. * Releases resources associated with this node.
  61667. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61668. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61669. */
  61670. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61671. }
  61672. }
  61673. declare module BABYLON {
  61674. /**
  61675. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61676. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61677. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61678. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61679. */
  61680. export class PhotoDome extends TextureDome<Texture> {
  61681. /**
  61682. * Define the image as a Monoscopic panoramic 360 image.
  61683. */
  61684. static readonly MODE_MONOSCOPIC: number;
  61685. /**
  61686. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61687. */
  61688. static readonly MODE_TOPBOTTOM: number;
  61689. /**
  61690. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61691. */
  61692. static readonly MODE_SIDEBYSIDE: number;
  61693. /**
  61694. * Gets or sets the texture being displayed on the sphere
  61695. */
  61696. get photoTexture(): Texture;
  61697. /**
  61698. * sets the texture being displayed on the sphere
  61699. */
  61700. set photoTexture(value: Texture);
  61701. /**
  61702. * Gets the current video mode for the video. It can be:
  61703. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61704. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61705. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61706. */
  61707. get imageMode(): number;
  61708. /**
  61709. * Sets the current video mode for the video. It can be:
  61710. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61711. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61712. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61713. */
  61714. set imageMode(value: number);
  61715. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61716. }
  61717. }
  61718. declare module BABYLON {
  61719. /**
  61720. * Direct draw surface info
  61721. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61722. */
  61723. export interface DDSInfo {
  61724. /**
  61725. * Width of the texture
  61726. */
  61727. width: number;
  61728. /**
  61729. * Width of the texture
  61730. */
  61731. height: number;
  61732. /**
  61733. * Number of Mipmaps for the texture
  61734. * @see https://en.wikipedia.org/wiki/Mipmap
  61735. */
  61736. mipmapCount: number;
  61737. /**
  61738. * If the textures format is a known fourCC format
  61739. * @see https://www.fourcc.org/
  61740. */
  61741. isFourCC: boolean;
  61742. /**
  61743. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61744. */
  61745. isRGB: boolean;
  61746. /**
  61747. * If the texture is a lumincance format
  61748. */
  61749. isLuminance: boolean;
  61750. /**
  61751. * If this is a cube texture
  61752. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61753. */
  61754. isCube: boolean;
  61755. /**
  61756. * If the texture is a compressed format eg. FOURCC_DXT1
  61757. */
  61758. isCompressed: boolean;
  61759. /**
  61760. * The dxgiFormat of the texture
  61761. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61762. */
  61763. dxgiFormat: number;
  61764. /**
  61765. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61766. */
  61767. textureType: number;
  61768. /**
  61769. * Sphericle polynomial created for the dds texture
  61770. */
  61771. sphericalPolynomial?: SphericalPolynomial;
  61772. }
  61773. /**
  61774. * Class used to provide DDS decompression tools
  61775. */
  61776. export class DDSTools {
  61777. /**
  61778. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61779. */
  61780. static StoreLODInAlphaChannel: boolean;
  61781. /**
  61782. * Gets DDS information from an array buffer
  61783. * @param data defines the array buffer view to read data from
  61784. * @returns the DDS information
  61785. */
  61786. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61787. private static _FloatView;
  61788. private static _Int32View;
  61789. private static _ToHalfFloat;
  61790. private static _FromHalfFloat;
  61791. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61792. private static _GetHalfFloatRGBAArrayBuffer;
  61793. private static _GetFloatRGBAArrayBuffer;
  61794. private static _GetFloatAsUIntRGBAArrayBuffer;
  61795. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61796. private static _GetRGBAArrayBuffer;
  61797. private static _ExtractLongWordOrder;
  61798. private static _GetRGBArrayBuffer;
  61799. private static _GetLuminanceArrayBuffer;
  61800. /**
  61801. * Uploads DDS Levels to a Babylon Texture
  61802. * @hidden
  61803. */
  61804. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61805. }
  61806. interface ThinEngine {
  61807. /**
  61808. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  61809. * @param rootUrl defines the url where the file to load is located
  61810. * @param scene defines the current scene
  61811. * @param lodScale defines scale to apply to the mip map selection
  61812. * @param lodOffset defines offset to apply to the mip map selection
  61813. * @param onLoad defines an optional callback raised when the texture is loaded
  61814. * @param onError defines an optional callback raised if there is an issue to load the texture
  61815. * @param format defines the format of the data
  61816. * @param forcedExtension defines the extension to use to pick the right loader
  61817. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61818. * @returns the cube texture as an InternalTexture
  61819. */
  61820. 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;
  61821. }
  61822. }
  61823. declare module BABYLON {
  61824. /**
  61825. * Implementation of the DDS Texture Loader.
  61826. * @hidden
  61827. */
  61828. export class _DDSTextureLoader implements IInternalTextureLoader {
  61829. /**
  61830. * Defines wether the loader supports cascade loading the different faces.
  61831. */
  61832. readonly supportCascades: boolean;
  61833. /**
  61834. * This returns if the loader support the current file information.
  61835. * @param extension defines the file extension of the file being loaded
  61836. * @returns true if the loader can load the specified file
  61837. */
  61838. canLoad(extension: string): boolean;
  61839. /**
  61840. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61841. * @param data contains the texture data
  61842. * @param texture defines the BabylonJS internal texture
  61843. * @param createPolynomials will be true if polynomials have been requested
  61844. * @param onLoad defines the callback to trigger once the texture is ready
  61845. * @param onError defines the callback to trigger in case of error
  61846. */
  61847. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61848. /**
  61849. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61850. * @param data contains the texture data
  61851. * @param texture defines the BabylonJS internal texture
  61852. * @param callback defines the method to call once ready to upload
  61853. */
  61854. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61855. }
  61856. }
  61857. declare module BABYLON {
  61858. /**
  61859. * Implementation of the ENV Texture Loader.
  61860. * @hidden
  61861. */
  61862. export class _ENVTextureLoader implements IInternalTextureLoader {
  61863. /**
  61864. * Defines wether the loader supports cascade loading the different faces.
  61865. */
  61866. readonly supportCascades: boolean;
  61867. /**
  61868. * This returns if the loader support the current file information.
  61869. * @param extension defines the file extension of the file being loaded
  61870. * @returns true if the loader can load the specified file
  61871. */
  61872. canLoad(extension: string): boolean;
  61873. /**
  61874. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61875. * @param data contains the texture data
  61876. * @param texture defines the BabylonJS internal texture
  61877. * @param createPolynomials will be true if polynomials have been requested
  61878. * @param onLoad defines the callback to trigger once the texture is ready
  61879. * @param onError defines the callback to trigger in case of error
  61880. */
  61881. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61882. /**
  61883. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61884. * @param data contains the texture data
  61885. * @param texture defines the BabylonJS internal texture
  61886. * @param callback defines the method to call once ready to upload
  61887. */
  61888. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61889. }
  61890. }
  61891. declare module BABYLON {
  61892. /**
  61893. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61894. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61895. */
  61896. export class KhronosTextureContainer {
  61897. /** contents of the KTX container file */
  61898. data: ArrayBufferView;
  61899. private static HEADER_LEN;
  61900. private static COMPRESSED_2D;
  61901. private static COMPRESSED_3D;
  61902. private static TEX_2D;
  61903. private static TEX_3D;
  61904. /**
  61905. * Gets the openGL type
  61906. */
  61907. glType: number;
  61908. /**
  61909. * Gets the openGL type size
  61910. */
  61911. glTypeSize: number;
  61912. /**
  61913. * Gets the openGL format
  61914. */
  61915. glFormat: number;
  61916. /**
  61917. * Gets the openGL internal format
  61918. */
  61919. glInternalFormat: number;
  61920. /**
  61921. * Gets the base internal format
  61922. */
  61923. glBaseInternalFormat: number;
  61924. /**
  61925. * Gets image width in pixel
  61926. */
  61927. pixelWidth: number;
  61928. /**
  61929. * Gets image height in pixel
  61930. */
  61931. pixelHeight: number;
  61932. /**
  61933. * Gets image depth in pixels
  61934. */
  61935. pixelDepth: number;
  61936. /**
  61937. * Gets the number of array elements
  61938. */
  61939. numberOfArrayElements: number;
  61940. /**
  61941. * Gets the number of faces
  61942. */
  61943. numberOfFaces: number;
  61944. /**
  61945. * Gets the number of mipmap levels
  61946. */
  61947. numberOfMipmapLevels: number;
  61948. /**
  61949. * Gets the bytes of key value data
  61950. */
  61951. bytesOfKeyValueData: number;
  61952. /**
  61953. * Gets the load type
  61954. */
  61955. loadType: number;
  61956. /**
  61957. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61958. */
  61959. isInvalid: boolean;
  61960. /**
  61961. * Creates a new KhronosTextureContainer
  61962. * @param data contents of the KTX container file
  61963. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61964. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61965. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61966. */
  61967. constructor(
  61968. /** contents of the KTX container file */
  61969. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61970. /**
  61971. * Uploads KTX content to a Babylon Texture.
  61972. * It is assumed that the texture has already been created & is currently bound
  61973. * @hidden
  61974. */
  61975. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61976. private _upload2DCompressedLevels;
  61977. /**
  61978. * Checks if the given data starts with a KTX file identifier.
  61979. * @param data the data to check
  61980. * @returns true if the data is a KTX file or false otherwise
  61981. */
  61982. static IsValid(data: ArrayBufferView): boolean;
  61983. }
  61984. }
  61985. declare module BABYLON {
  61986. /**
  61987. * Helper class to push actions to a pool of workers.
  61988. */
  61989. export class WorkerPool implements IDisposable {
  61990. private _workerInfos;
  61991. private _pendingActions;
  61992. /**
  61993. * Constructor
  61994. * @param workers Array of workers to use for actions
  61995. */
  61996. constructor(workers: Array<Worker>);
  61997. /**
  61998. * Terminates all workers and clears any pending actions.
  61999. */
  62000. dispose(): void;
  62001. /**
  62002. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62003. * pended until a worker has completed its action.
  62004. * @param action The action to perform. Call onComplete when the action is complete.
  62005. */
  62006. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62007. private _execute;
  62008. }
  62009. }
  62010. declare module BABYLON {
  62011. /**
  62012. * Class for loading KTX2 files
  62013. */
  62014. export class KhronosTextureContainer2 {
  62015. private static _WorkerPoolPromise?;
  62016. private static _Initialized;
  62017. private static _Ktx2Decoder;
  62018. /**
  62019. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62020. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62021. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62022. * Urls you can change:
  62023. * URLConfig.jsDecoderModule
  62024. * URLConfig.wasmUASTCToASTC
  62025. * URLConfig.wasmUASTCToBC7
  62026. * URLConfig.wasmUASTCToRGBA_UNORM
  62027. * URLConfig.wasmUASTCToRGBA_SRGB
  62028. * URLConfig.jsMSCTranscoder
  62029. * URLConfig.wasmMSCTranscoder
  62030. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  62031. */
  62032. static URLConfig: {
  62033. jsDecoderModule: string;
  62034. wasmUASTCToASTC: null;
  62035. wasmUASTCToBC7: null;
  62036. wasmUASTCToRGBA_UNORM: null;
  62037. wasmUASTCToRGBA_SRGB: null;
  62038. jsMSCTranscoder: null;
  62039. wasmMSCTranscoder: null;
  62040. };
  62041. /**
  62042. * Default number of workers used to handle data decoding
  62043. */
  62044. static DefaultNumWorkers: number;
  62045. private static GetDefaultNumWorkers;
  62046. private _engine;
  62047. private static _CreateWorkerPool;
  62048. /**
  62049. * Constructor
  62050. * @param engine The engine to use
  62051. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62052. */
  62053. constructor(engine: ThinEngine, numWorkers?: number);
  62054. /** @hidden */
  62055. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62056. /**
  62057. * Stop all async operations and release resources.
  62058. */
  62059. dispose(): void;
  62060. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62061. /**
  62062. * Checks if the given data starts with a KTX2 file identifier.
  62063. * @param data the data to check
  62064. * @returns true if the data is a KTX2 file or false otherwise
  62065. */
  62066. static IsValid(data: ArrayBufferView): boolean;
  62067. }
  62068. }
  62069. declare module BABYLON {
  62070. /**
  62071. * Implementation of the KTX Texture Loader.
  62072. * @hidden
  62073. */
  62074. export class _KTXTextureLoader implements IInternalTextureLoader {
  62075. /**
  62076. * Defines wether the loader supports cascade loading the different faces.
  62077. */
  62078. readonly supportCascades: boolean;
  62079. /**
  62080. * This returns if the loader support the current file information.
  62081. * @param extension defines the file extension of the file being loaded
  62082. * @param mimeType defines the optional mime type of the file being loaded
  62083. * @returns true if the loader can load the specified file
  62084. */
  62085. canLoad(extension: string, mimeType?: string): boolean;
  62086. /**
  62087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62088. * @param data contains the texture data
  62089. * @param texture defines the BabylonJS internal texture
  62090. * @param createPolynomials will be true if polynomials have been requested
  62091. * @param onLoad defines the callback to trigger once the texture is ready
  62092. * @param onError defines the callback to trigger in case of error
  62093. */
  62094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62095. /**
  62096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62097. * @param data contains the texture data
  62098. * @param texture defines the BabylonJS internal texture
  62099. * @param callback defines the method to call once ready to upload
  62100. */
  62101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62102. }
  62103. }
  62104. declare module BABYLON {
  62105. /** @hidden */
  62106. export var _forceSceneHelpersToBundle: boolean;
  62107. interface Scene {
  62108. /**
  62109. * Creates a default light for the scene.
  62110. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62111. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62112. */
  62113. createDefaultLight(replace?: boolean): void;
  62114. /**
  62115. * Creates a default camera for the scene.
  62116. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62117. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62118. * @param replace has default false, when true replaces the active camera in the scene
  62119. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62120. */
  62121. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62122. /**
  62123. * Creates a default camera and a default light.
  62124. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62125. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62126. * @param replace has the default false, when true replaces the active camera/light in the scene
  62127. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62128. */
  62129. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62130. /**
  62131. * Creates a new sky box
  62132. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62133. * @param environmentTexture defines the texture to use as environment texture
  62134. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62135. * @param scale defines the overall scale of the skybox
  62136. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62137. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62138. * @returns a new mesh holding the sky box
  62139. */
  62140. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62141. /**
  62142. * Creates a new environment
  62143. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62144. * @param options defines the options you can use to configure the environment
  62145. * @returns the new EnvironmentHelper
  62146. */
  62147. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62148. /**
  62149. * Creates a new VREXperienceHelper
  62150. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62151. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62152. * @returns a new VREXperienceHelper
  62153. */
  62154. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62155. /**
  62156. * Creates a new WebXRDefaultExperience
  62157. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62158. * @param options experience options
  62159. * @returns a promise for a new WebXRDefaultExperience
  62160. */
  62161. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62162. }
  62163. }
  62164. declare module BABYLON {
  62165. /**
  62166. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62167. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62168. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62169. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62170. */
  62171. export class VideoDome extends TextureDome<VideoTexture> {
  62172. /**
  62173. * Define the video source as a Monoscopic panoramic 360 video.
  62174. */
  62175. static readonly MODE_MONOSCOPIC: number;
  62176. /**
  62177. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62178. */
  62179. static readonly MODE_TOPBOTTOM: number;
  62180. /**
  62181. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62182. */
  62183. static readonly MODE_SIDEBYSIDE: number;
  62184. /**
  62185. * Get the video texture associated with this video dome
  62186. */
  62187. get videoTexture(): VideoTexture;
  62188. /**
  62189. * Get the video mode of this dome
  62190. */
  62191. get videoMode(): number;
  62192. /**
  62193. * Set the video mode of this dome.
  62194. * @see textureMode
  62195. */
  62196. set videoMode(value: number);
  62197. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62198. }
  62199. }
  62200. declare module BABYLON {
  62201. /**
  62202. * This class can be used to get instrumentation data from a Babylon engine
  62203. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62204. */
  62205. export class EngineInstrumentation implements IDisposable {
  62206. /**
  62207. * Define the instrumented engine.
  62208. */
  62209. engine: Engine;
  62210. private _captureGPUFrameTime;
  62211. private _gpuFrameTimeToken;
  62212. private _gpuFrameTime;
  62213. private _captureShaderCompilationTime;
  62214. private _shaderCompilationTime;
  62215. private _onBeginFrameObserver;
  62216. private _onEndFrameObserver;
  62217. private _onBeforeShaderCompilationObserver;
  62218. private _onAfterShaderCompilationObserver;
  62219. /**
  62220. * Gets the perf counter used for GPU frame time
  62221. */
  62222. get gpuFrameTimeCounter(): PerfCounter;
  62223. /**
  62224. * Gets the GPU frame time capture status
  62225. */
  62226. get captureGPUFrameTime(): boolean;
  62227. /**
  62228. * Enable or disable the GPU frame time capture
  62229. */
  62230. set captureGPUFrameTime(value: boolean);
  62231. /**
  62232. * Gets the perf counter used for shader compilation time
  62233. */
  62234. get shaderCompilationTimeCounter(): PerfCounter;
  62235. /**
  62236. * Gets the shader compilation time capture status
  62237. */
  62238. get captureShaderCompilationTime(): boolean;
  62239. /**
  62240. * Enable or disable the shader compilation time capture
  62241. */
  62242. set captureShaderCompilationTime(value: boolean);
  62243. /**
  62244. * Instantiates a new engine instrumentation.
  62245. * This class can be used to get instrumentation data from a Babylon engine
  62246. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62247. * @param engine Defines the engine to instrument
  62248. */
  62249. constructor(
  62250. /**
  62251. * Define the instrumented engine.
  62252. */
  62253. engine: Engine);
  62254. /**
  62255. * Dispose and release associated resources.
  62256. */
  62257. dispose(): void;
  62258. }
  62259. }
  62260. declare module BABYLON {
  62261. /**
  62262. * This class can be used to get instrumentation data from a Babylon engine
  62263. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62264. */
  62265. export class SceneInstrumentation implements IDisposable {
  62266. /**
  62267. * Defines the scene to instrument
  62268. */
  62269. scene: Scene;
  62270. private _captureActiveMeshesEvaluationTime;
  62271. private _activeMeshesEvaluationTime;
  62272. private _captureRenderTargetsRenderTime;
  62273. private _renderTargetsRenderTime;
  62274. private _captureFrameTime;
  62275. private _frameTime;
  62276. private _captureRenderTime;
  62277. private _renderTime;
  62278. private _captureInterFrameTime;
  62279. private _interFrameTime;
  62280. private _captureParticlesRenderTime;
  62281. private _particlesRenderTime;
  62282. private _captureSpritesRenderTime;
  62283. private _spritesRenderTime;
  62284. private _capturePhysicsTime;
  62285. private _physicsTime;
  62286. private _captureAnimationsTime;
  62287. private _animationsTime;
  62288. private _captureCameraRenderTime;
  62289. private _cameraRenderTime;
  62290. private _onBeforeActiveMeshesEvaluationObserver;
  62291. private _onAfterActiveMeshesEvaluationObserver;
  62292. private _onBeforeRenderTargetsRenderObserver;
  62293. private _onAfterRenderTargetsRenderObserver;
  62294. private _onAfterRenderObserver;
  62295. private _onBeforeDrawPhaseObserver;
  62296. private _onAfterDrawPhaseObserver;
  62297. private _onBeforeAnimationsObserver;
  62298. private _onBeforeParticlesRenderingObserver;
  62299. private _onAfterParticlesRenderingObserver;
  62300. private _onBeforeSpritesRenderingObserver;
  62301. private _onAfterSpritesRenderingObserver;
  62302. private _onBeforePhysicsObserver;
  62303. private _onAfterPhysicsObserver;
  62304. private _onAfterAnimationsObserver;
  62305. private _onBeforeCameraRenderObserver;
  62306. private _onAfterCameraRenderObserver;
  62307. /**
  62308. * Gets the perf counter used for active meshes evaluation time
  62309. */
  62310. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62311. /**
  62312. * Gets the active meshes evaluation time capture status
  62313. */
  62314. get captureActiveMeshesEvaluationTime(): boolean;
  62315. /**
  62316. * Enable or disable the active meshes evaluation time capture
  62317. */
  62318. set captureActiveMeshesEvaluationTime(value: boolean);
  62319. /**
  62320. * Gets the perf counter used for render targets render time
  62321. */
  62322. get renderTargetsRenderTimeCounter(): PerfCounter;
  62323. /**
  62324. * Gets the render targets render time capture status
  62325. */
  62326. get captureRenderTargetsRenderTime(): boolean;
  62327. /**
  62328. * Enable or disable the render targets render time capture
  62329. */
  62330. set captureRenderTargetsRenderTime(value: boolean);
  62331. /**
  62332. * Gets the perf counter used for particles render time
  62333. */
  62334. get particlesRenderTimeCounter(): PerfCounter;
  62335. /**
  62336. * Gets the particles render time capture status
  62337. */
  62338. get captureParticlesRenderTime(): boolean;
  62339. /**
  62340. * Enable or disable the particles render time capture
  62341. */
  62342. set captureParticlesRenderTime(value: boolean);
  62343. /**
  62344. * Gets the perf counter used for sprites render time
  62345. */
  62346. get spritesRenderTimeCounter(): PerfCounter;
  62347. /**
  62348. * Gets the sprites render time capture status
  62349. */
  62350. get captureSpritesRenderTime(): boolean;
  62351. /**
  62352. * Enable or disable the sprites render time capture
  62353. */
  62354. set captureSpritesRenderTime(value: boolean);
  62355. /**
  62356. * Gets the perf counter used for physics time
  62357. */
  62358. get physicsTimeCounter(): PerfCounter;
  62359. /**
  62360. * Gets the physics time capture status
  62361. */
  62362. get capturePhysicsTime(): boolean;
  62363. /**
  62364. * Enable or disable the physics time capture
  62365. */
  62366. set capturePhysicsTime(value: boolean);
  62367. /**
  62368. * Gets the perf counter used for animations time
  62369. */
  62370. get animationsTimeCounter(): PerfCounter;
  62371. /**
  62372. * Gets the animations time capture status
  62373. */
  62374. get captureAnimationsTime(): boolean;
  62375. /**
  62376. * Enable or disable the animations time capture
  62377. */
  62378. set captureAnimationsTime(value: boolean);
  62379. /**
  62380. * Gets the perf counter used for frame time capture
  62381. */
  62382. get frameTimeCounter(): PerfCounter;
  62383. /**
  62384. * Gets the frame time capture status
  62385. */
  62386. get captureFrameTime(): boolean;
  62387. /**
  62388. * Enable or disable the frame time capture
  62389. */
  62390. set captureFrameTime(value: boolean);
  62391. /**
  62392. * Gets the perf counter used for inter-frames time capture
  62393. */
  62394. get interFrameTimeCounter(): PerfCounter;
  62395. /**
  62396. * Gets the inter-frames time capture status
  62397. */
  62398. get captureInterFrameTime(): boolean;
  62399. /**
  62400. * Enable or disable the inter-frames time capture
  62401. */
  62402. set captureInterFrameTime(value: boolean);
  62403. /**
  62404. * Gets the perf counter used for render time capture
  62405. */
  62406. get renderTimeCounter(): PerfCounter;
  62407. /**
  62408. * Gets the render time capture status
  62409. */
  62410. get captureRenderTime(): boolean;
  62411. /**
  62412. * Enable or disable the render time capture
  62413. */
  62414. set captureRenderTime(value: boolean);
  62415. /**
  62416. * Gets the perf counter used for camera render time capture
  62417. */
  62418. get cameraRenderTimeCounter(): PerfCounter;
  62419. /**
  62420. * Gets the camera render time capture status
  62421. */
  62422. get captureCameraRenderTime(): boolean;
  62423. /**
  62424. * Enable or disable the camera render time capture
  62425. */
  62426. set captureCameraRenderTime(value: boolean);
  62427. /**
  62428. * Gets the perf counter used for draw calls
  62429. */
  62430. get drawCallsCounter(): PerfCounter;
  62431. /**
  62432. * Instantiates a new scene instrumentation.
  62433. * This class can be used to get instrumentation data from a Babylon engine
  62434. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62435. * @param scene Defines the scene to instrument
  62436. */
  62437. constructor(
  62438. /**
  62439. * Defines the scene to instrument
  62440. */
  62441. scene: Scene);
  62442. /**
  62443. * Dispose and release associated resources.
  62444. */
  62445. dispose(): void;
  62446. }
  62447. }
  62448. declare module BABYLON {
  62449. /** @hidden */
  62450. export var glowMapGenerationPixelShader: {
  62451. name: string;
  62452. shader: string;
  62453. };
  62454. }
  62455. declare module BABYLON {
  62456. /** @hidden */
  62457. export var glowMapGenerationVertexShader: {
  62458. name: string;
  62459. shader: string;
  62460. };
  62461. }
  62462. declare module BABYLON {
  62463. /**
  62464. * Effect layer options. This helps customizing the behaviour
  62465. * of the effect layer.
  62466. */
  62467. export interface IEffectLayerOptions {
  62468. /**
  62469. * Multiplication factor apply to the canvas size to compute the render target size
  62470. * used to generated the objects (the smaller the faster).
  62471. */
  62472. mainTextureRatio: number;
  62473. /**
  62474. * Enforces a fixed size texture to ensure effect stability across devices.
  62475. */
  62476. mainTextureFixedSize?: number;
  62477. /**
  62478. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62479. */
  62480. alphaBlendingMode: number;
  62481. /**
  62482. * The camera attached to the layer.
  62483. */
  62484. camera: Nullable<Camera>;
  62485. /**
  62486. * The rendering group to draw the layer in.
  62487. */
  62488. renderingGroupId: number;
  62489. }
  62490. /**
  62491. * The effect layer Helps adding post process effect blended with the main pass.
  62492. *
  62493. * This can be for instance use to generate glow or higlight effects on the scene.
  62494. *
  62495. * The effect layer class can not be used directly and is intented to inherited from to be
  62496. * customized per effects.
  62497. */
  62498. export abstract class EffectLayer {
  62499. private _vertexBuffers;
  62500. private _indexBuffer;
  62501. private _cachedDefines;
  62502. private _effectLayerMapGenerationEffect;
  62503. private _effectLayerOptions;
  62504. private _mergeEffect;
  62505. protected _scene: Scene;
  62506. protected _engine: Engine;
  62507. protected _maxSize: number;
  62508. protected _mainTextureDesiredSize: ISize;
  62509. protected _mainTexture: RenderTargetTexture;
  62510. protected _shouldRender: boolean;
  62511. protected _postProcesses: PostProcess[];
  62512. protected _textures: BaseTexture[];
  62513. protected _emissiveTextureAndColor: {
  62514. texture: Nullable<BaseTexture>;
  62515. color: Color4;
  62516. };
  62517. /**
  62518. * The name of the layer
  62519. */
  62520. name: string;
  62521. /**
  62522. * The clear color of the texture used to generate the glow map.
  62523. */
  62524. neutralColor: Color4;
  62525. /**
  62526. * Specifies whether the highlight layer is enabled or not.
  62527. */
  62528. isEnabled: boolean;
  62529. /**
  62530. * Gets the camera attached to the layer.
  62531. */
  62532. get camera(): Nullable<Camera>;
  62533. /**
  62534. * Gets the rendering group id the layer should render in.
  62535. */
  62536. get renderingGroupId(): number;
  62537. set renderingGroupId(renderingGroupId: number);
  62538. /**
  62539. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62540. */
  62541. disableBoundingBoxesFromEffectLayer: boolean;
  62542. /**
  62543. * An event triggered when the effect layer has been disposed.
  62544. */
  62545. onDisposeObservable: Observable<EffectLayer>;
  62546. /**
  62547. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62548. */
  62549. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62550. /**
  62551. * An event triggered when the generated texture is being merged in the scene.
  62552. */
  62553. onBeforeComposeObservable: Observable<EffectLayer>;
  62554. /**
  62555. * An event triggered when the mesh is rendered into the effect render target.
  62556. */
  62557. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62558. /**
  62559. * An event triggered after the mesh has been rendered into the effect render target.
  62560. */
  62561. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62562. /**
  62563. * An event triggered when the generated texture has been merged in the scene.
  62564. */
  62565. onAfterComposeObservable: Observable<EffectLayer>;
  62566. /**
  62567. * An event triggered when the efffect layer changes its size.
  62568. */
  62569. onSizeChangedObservable: Observable<EffectLayer>;
  62570. /** @hidden */
  62571. static _SceneComponentInitialization: (scene: Scene) => void;
  62572. /**
  62573. * Instantiates a new effect Layer and references it in the scene.
  62574. * @param name The name of the layer
  62575. * @param scene The scene to use the layer in
  62576. */
  62577. constructor(
  62578. /** The Friendly of the effect in the scene */
  62579. name: string, scene: Scene);
  62580. /**
  62581. * Get the effect name of the layer.
  62582. * @return The effect name
  62583. */
  62584. abstract getEffectName(): string;
  62585. /**
  62586. * Checks for the readiness of the element composing the layer.
  62587. * @param subMesh the mesh to check for
  62588. * @param useInstances specify whether or not to use instances to render the mesh
  62589. * @return true if ready otherwise, false
  62590. */
  62591. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62592. /**
  62593. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62594. * @returns true if the effect requires stencil during the main canvas render pass.
  62595. */
  62596. abstract needStencil(): boolean;
  62597. /**
  62598. * Create the merge effect. This is the shader use to blit the information back
  62599. * to the main canvas at the end of the scene rendering.
  62600. * @returns The effect containing the shader used to merge the effect on the main canvas
  62601. */
  62602. protected abstract _createMergeEffect(): Effect;
  62603. /**
  62604. * Creates the render target textures and post processes used in the effect layer.
  62605. */
  62606. protected abstract _createTextureAndPostProcesses(): void;
  62607. /**
  62608. * Implementation specific of rendering the generating effect on the main canvas.
  62609. * @param effect The effect used to render through
  62610. */
  62611. protected abstract _internalRender(effect: Effect): void;
  62612. /**
  62613. * Sets the required values for both the emissive texture and and the main color.
  62614. */
  62615. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62616. /**
  62617. * Free any resources and references associated to a mesh.
  62618. * Internal use
  62619. * @param mesh The mesh to free.
  62620. */
  62621. abstract _disposeMesh(mesh: Mesh): void;
  62622. /**
  62623. * Serializes this layer (Glow or Highlight for example)
  62624. * @returns a serialized layer object
  62625. */
  62626. abstract serialize?(): any;
  62627. /**
  62628. * Initializes the effect layer with the required options.
  62629. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62630. */
  62631. protected _init(options: Partial<IEffectLayerOptions>): void;
  62632. /**
  62633. * Generates the index buffer of the full screen quad blending to the main canvas.
  62634. */
  62635. private _generateIndexBuffer;
  62636. /**
  62637. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62638. */
  62639. private _generateVertexBuffer;
  62640. /**
  62641. * Sets the main texture desired size which is the closest power of two
  62642. * of the engine canvas size.
  62643. */
  62644. private _setMainTextureSize;
  62645. /**
  62646. * Creates the main texture for the effect layer.
  62647. */
  62648. protected _createMainTexture(): void;
  62649. /**
  62650. * Adds specific effects defines.
  62651. * @param defines The defines to add specifics to.
  62652. */
  62653. protected _addCustomEffectDefines(defines: string[]): void;
  62654. /**
  62655. * Checks for the readiness of the element composing the layer.
  62656. * @param subMesh the mesh to check for
  62657. * @param useInstances specify whether or not to use instances to render the mesh
  62658. * @param emissiveTexture the associated emissive texture used to generate the glow
  62659. * @return true if ready otherwise, false
  62660. */
  62661. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62662. /**
  62663. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62664. */
  62665. render(): void;
  62666. /**
  62667. * Determine if a given mesh will be used in the current effect.
  62668. * @param mesh mesh to test
  62669. * @returns true if the mesh will be used
  62670. */
  62671. hasMesh(mesh: AbstractMesh): boolean;
  62672. /**
  62673. * Returns true if the layer contains information to display, otherwise false.
  62674. * @returns true if the glow layer should be rendered
  62675. */
  62676. shouldRender(): boolean;
  62677. /**
  62678. * Returns true if the mesh should render, otherwise false.
  62679. * @param mesh The mesh to render
  62680. * @returns true if it should render otherwise false
  62681. */
  62682. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62683. /**
  62684. * Returns true if the mesh can be rendered, otherwise false.
  62685. * @param mesh The mesh to render
  62686. * @param material The material used on the mesh
  62687. * @returns true if it can be rendered otherwise false
  62688. */
  62689. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62690. /**
  62691. * Returns true if the mesh should render, otherwise false.
  62692. * @param mesh The mesh to render
  62693. * @returns true if it should render otherwise false
  62694. */
  62695. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62696. /**
  62697. * Renders the submesh passed in parameter to the generation map.
  62698. */
  62699. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62700. /**
  62701. * Defines whether the current material of the mesh should be use to render the effect.
  62702. * @param mesh defines the current mesh to render
  62703. */
  62704. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62705. /**
  62706. * Rebuild the required buffers.
  62707. * @hidden Internal use only.
  62708. */
  62709. _rebuild(): void;
  62710. /**
  62711. * Dispose only the render target textures and post process.
  62712. */
  62713. private _disposeTextureAndPostProcesses;
  62714. /**
  62715. * Dispose the highlight layer and free resources.
  62716. */
  62717. dispose(): void;
  62718. /**
  62719. * Gets the class name of the effect layer
  62720. * @returns the string with the class name of the effect layer
  62721. */
  62722. getClassName(): string;
  62723. /**
  62724. * Creates an effect layer from parsed effect layer data
  62725. * @param parsedEffectLayer defines effect layer data
  62726. * @param scene defines the current scene
  62727. * @param rootUrl defines the root URL containing the effect layer information
  62728. * @returns a parsed effect Layer
  62729. */
  62730. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62731. }
  62732. }
  62733. declare module BABYLON {
  62734. interface AbstractScene {
  62735. /**
  62736. * The list of effect layers (highlights/glow) added to the scene
  62737. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62738. * @see https://doc.babylonjs.com/how_to/glow_layer
  62739. */
  62740. effectLayers: Array<EffectLayer>;
  62741. /**
  62742. * Removes the given effect layer from this scene.
  62743. * @param toRemove defines the effect layer to remove
  62744. * @returns the index of the removed effect layer
  62745. */
  62746. removeEffectLayer(toRemove: EffectLayer): number;
  62747. /**
  62748. * Adds the given effect layer to this scene
  62749. * @param newEffectLayer defines the effect layer to add
  62750. */
  62751. addEffectLayer(newEffectLayer: EffectLayer): void;
  62752. }
  62753. /**
  62754. * Defines the layer scene component responsible to manage any effect layers
  62755. * in a given scene.
  62756. */
  62757. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62758. /**
  62759. * The component name helpfull to identify the component in the list of scene components.
  62760. */
  62761. readonly name: string;
  62762. /**
  62763. * The scene the component belongs to.
  62764. */
  62765. scene: Scene;
  62766. private _engine;
  62767. private _renderEffects;
  62768. private _needStencil;
  62769. private _previousStencilState;
  62770. /**
  62771. * Creates a new instance of the component for the given scene
  62772. * @param scene Defines the scene to register the component in
  62773. */
  62774. constructor(scene: Scene);
  62775. /**
  62776. * Registers the component in a given scene
  62777. */
  62778. register(): void;
  62779. /**
  62780. * Rebuilds the elements related to this component in case of
  62781. * context lost for instance.
  62782. */
  62783. rebuild(): void;
  62784. /**
  62785. * Serializes the component data to the specified json object
  62786. * @param serializationObject The object to serialize to
  62787. */
  62788. serialize(serializationObject: any): void;
  62789. /**
  62790. * Adds all the elements from the container to the scene
  62791. * @param container the container holding the elements
  62792. */
  62793. addFromContainer(container: AbstractScene): void;
  62794. /**
  62795. * Removes all the elements in the container from the scene
  62796. * @param container contains the elements to remove
  62797. * @param dispose if the removed element should be disposed (default: false)
  62798. */
  62799. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62800. /**
  62801. * Disposes the component and the associated ressources.
  62802. */
  62803. dispose(): void;
  62804. private _isReadyForMesh;
  62805. private _renderMainTexture;
  62806. private _setStencil;
  62807. private _setStencilBack;
  62808. private _draw;
  62809. private _drawCamera;
  62810. private _drawRenderingGroup;
  62811. }
  62812. }
  62813. declare module BABYLON {
  62814. /** @hidden */
  62815. export var glowMapMergePixelShader: {
  62816. name: string;
  62817. shader: string;
  62818. };
  62819. }
  62820. declare module BABYLON {
  62821. /** @hidden */
  62822. export var glowMapMergeVertexShader: {
  62823. name: string;
  62824. shader: string;
  62825. };
  62826. }
  62827. declare module BABYLON {
  62828. interface AbstractScene {
  62829. /**
  62830. * Return a the first highlight layer of the scene with a given name.
  62831. * @param name The name of the highlight layer to look for.
  62832. * @return The highlight layer if found otherwise null.
  62833. */
  62834. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62835. }
  62836. /**
  62837. * Glow layer options. This helps customizing the behaviour
  62838. * of the glow layer.
  62839. */
  62840. export interface IGlowLayerOptions {
  62841. /**
  62842. * Multiplication factor apply to the canvas size to compute the render target size
  62843. * used to generated the glowing objects (the smaller the faster).
  62844. */
  62845. mainTextureRatio: number;
  62846. /**
  62847. * Enforces a fixed size texture to ensure resize independant blur.
  62848. */
  62849. mainTextureFixedSize?: number;
  62850. /**
  62851. * How big is the kernel of the blur texture.
  62852. */
  62853. blurKernelSize: number;
  62854. /**
  62855. * The camera attached to the layer.
  62856. */
  62857. camera: Nullable<Camera>;
  62858. /**
  62859. * Enable MSAA by chosing the number of samples.
  62860. */
  62861. mainTextureSamples?: number;
  62862. /**
  62863. * The rendering group to draw the layer in.
  62864. */
  62865. renderingGroupId: number;
  62866. }
  62867. /**
  62868. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62869. *
  62870. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62871. *
  62872. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62873. */
  62874. export class GlowLayer extends EffectLayer {
  62875. /**
  62876. * Effect Name of the layer.
  62877. */
  62878. static readonly EffectName: string;
  62879. /**
  62880. * The default blur kernel size used for the glow.
  62881. */
  62882. static DefaultBlurKernelSize: number;
  62883. /**
  62884. * The default texture size ratio used for the glow.
  62885. */
  62886. static DefaultTextureRatio: number;
  62887. /**
  62888. * Sets the kernel size of the blur.
  62889. */
  62890. set blurKernelSize(value: number);
  62891. /**
  62892. * Gets the kernel size of the blur.
  62893. */
  62894. get blurKernelSize(): number;
  62895. /**
  62896. * Sets the glow intensity.
  62897. */
  62898. set intensity(value: number);
  62899. /**
  62900. * Gets the glow intensity.
  62901. */
  62902. get intensity(): number;
  62903. private _options;
  62904. private _intensity;
  62905. private _horizontalBlurPostprocess1;
  62906. private _verticalBlurPostprocess1;
  62907. private _horizontalBlurPostprocess2;
  62908. private _verticalBlurPostprocess2;
  62909. private _blurTexture1;
  62910. private _blurTexture2;
  62911. private _postProcesses1;
  62912. private _postProcesses2;
  62913. private _includedOnlyMeshes;
  62914. private _excludedMeshes;
  62915. private _meshesUsingTheirOwnMaterials;
  62916. /**
  62917. * Callback used to let the user override the color selection on a per mesh basis
  62918. */
  62919. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62920. /**
  62921. * Callback used to let the user override the texture selection on a per mesh basis
  62922. */
  62923. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62924. /**
  62925. * Instantiates a new glow Layer and references it to the scene.
  62926. * @param name The name of the layer
  62927. * @param scene The scene to use the layer in
  62928. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62929. */
  62930. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62931. /**
  62932. * Get the effect name of the layer.
  62933. * @return The effect name
  62934. */
  62935. getEffectName(): string;
  62936. /**
  62937. * Create the merge effect. This is the shader use to blit the information back
  62938. * to the main canvas at the end of the scene rendering.
  62939. */
  62940. protected _createMergeEffect(): Effect;
  62941. /**
  62942. * Creates the render target textures and post processes used in the glow layer.
  62943. */
  62944. protected _createTextureAndPostProcesses(): void;
  62945. /**
  62946. * Checks for the readiness of the element composing the layer.
  62947. * @param subMesh the mesh to check for
  62948. * @param useInstances specify wether or not to use instances to render the mesh
  62949. * @param emissiveTexture the associated emissive texture used to generate the glow
  62950. * @return true if ready otherwise, false
  62951. */
  62952. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62953. /**
  62954. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62955. */
  62956. needStencil(): boolean;
  62957. /**
  62958. * Returns true if the mesh can be rendered, otherwise false.
  62959. * @param mesh The mesh to render
  62960. * @param material The material used on the mesh
  62961. * @returns true if it can be rendered otherwise false
  62962. */
  62963. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62964. /**
  62965. * Implementation specific of rendering the generating effect on the main canvas.
  62966. * @param effect The effect used to render through
  62967. */
  62968. protected _internalRender(effect: Effect): void;
  62969. /**
  62970. * Sets the required values for both the emissive texture and and the main color.
  62971. */
  62972. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62973. /**
  62974. * Returns true if the mesh should render, otherwise false.
  62975. * @param mesh The mesh to render
  62976. * @returns true if it should render otherwise false
  62977. */
  62978. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62979. /**
  62980. * Adds specific effects defines.
  62981. * @param defines The defines to add specifics to.
  62982. */
  62983. protected _addCustomEffectDefines(defines: string[]): void;
  62984. /**
  62985. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62986. * @param mesh The mesh to exclude from the glow layer
  62987. */
  62988. addExcludedMesh(mesh: Mesh): void;
  62989. /**
  62990. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62991. * @param mesh The mesh to remove
  62992. */
  62993. removeExcludedMesh(mesh: Mesh): void;
  62994. /**
  62995. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62996. * @param mesh The mesh to include in the glow layer
  62997. */
  62998. addIncludedOnlyMesh(mesh: Mesh): void;
  62999. /**
  63000. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63001. * @param mesh The mesh to remove
  63002. */
  63003. removeIncludedOnlyMesh(mesh: Mesh): void;
  63004. /**
  63005. * Determine if a given mesh will be used in the glow layer
  63006. * @param mesh The mesh to test
  63007. * @returns true if the mesh will be highlighted by the current glow layer
  63008. */
  63009. hasMesh(mesh: AbstractMesh): boolean;
  63010. /**
  63011. * Defines whether the current material of the mesh should be use to render the effect.
  63012. * @param mesh defines the current mesh to render
  63013. */
  63014. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63015. /**
  63016. * Add a mesh to be rendered through its own material and not with emissive only.
  63017. * @param mesh The mesh for which we need to use its material
  63018. */
  63019. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63020. /**
  63021. * Remove a mesh from being rendered through its own material and not with emissive only.
  63022. * @param mesh The mesh for which we need to not use its material
  63023. */
  63024. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63025. /**
  63026. * Free any resources and references associated to a mesh.
  63027. * Internal use
  63028. * @param mesh The mesh to free.
  63029. * @hidden
  63030. */
  63031. _disposeMesh(mesh: Mesh): void;
  63032. /**
  63033. * Gets the class name of the effect layer
  63034. * @returns the string with the class name of the effect layer
  63035. */
  63036. getClassName(): string;
  63037. /**
  63038. * Serializes this glow layer
  63039. * @returns a serialized glow layer object
  63040. */
  63041. serialize(): any;
  63042. /**
  63043. * Creates a Glow Layer from parsed glow layer data
  63044. * @param parsedGlowLayer defines glow layer data
  63045. * @param scene defines the current scene
  63046. * @param rootUrl defines the root URL containing the glow layer information
  63047. * @returns a parsed Glow Layer
  63048. */
  63049. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63050. }
  63051. }
  63052. declare module BABYLON {
  63053. /** @hidden */
  63054. export var glowBlurPostProcessPixelShader: {
  63055. name: string;
  63056. shader: string;
  63057. };
  63058. }
  63059. declare module BABYLON {
  63060. interface AbstractScene {
  63061. /**
  63062. * Return a the first highlight layer of the scene with a given name.
  63063. * @param name The name of the highlight layer to look for.
  63064. * @return The highlight layer if found otherwise null.
  63065. */
  63066. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63067. }
  63068. /**
  63069. * Highlight layer options. This helps customizing the behaviour
  63070. * of the highlight layer.
  63071. */
  63072. export interface IHighlightLayerOptions {
  63073. /**
  63074. * Multiplication factor apply to the canvas size to compute the render target size
  63075. * used to generated the glowing objects (the smaller the faster).
  63076. */
  63077. mainTextureRatio: number;
  63078. /**
  63079. * Enforces a fixed size texture to ensure resize independant blur.
  63080. */
  63081. mainTextureFixedSize?: number;
  63082. /**
  63083. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63084. * of the picture to blur (the smaller the faster).
  63085. */
  63086. blurTextureSizeRatio: number;
  63087. /**
  63088. * How big in texel of the blur texture is the vertical blur.
  63089. */
  63090. blurVerticalSize: number;
  63091. /**
  63092. * How big in texel of the blur texture is the horizontal blur.
  63093. */
  63094. blurHorizontalSize: number;
  63095. /**
  63096. * Alpha blending mode used to apply the blur. Default is combine.
  63097. */
  63098. alphaBlendingMode: number;
  63099. /**
  63100. * The camera attached to the layer.
  63101. */
  63102. camera: Nullable<Camera>;
  63103. /**
  63104. * Should we display highlight as a solid stroke?
  63105. */
  63106. isStroke?: boolean;
  63107. /**
  63108. * The rendering group to draw the layer in.
  63109. */
  63110. renderingGroupId: number;
  63111. }
  63112. /**
  63113. * The highlight layer Helps adding a glow effect around a mesh.
  63114. *
  63115. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63116. * glowy meshes to your scene.
  63117. *
  63118. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63119. */
  63120. export class HighlightLayer extends EffectLayer {
  63121. name: string;
  63122. /**
  63123. * Effect Name of the highlight layer.
  63124. */
  63125. static readonly EffectName: string;
  63126. /**
  63127. * The neutral color used during the preparation of the glow effect.
  63128. * This is black by default as the blend operation is a blend operation.
  63129. */
  63130. static NeutralColor: Color4;
  63131. /**
  63132. * Stencil value used for glowing meshes.
  63133. */
  63134. static GlowingMeshStencilReference: number;
  63135. /**
  63136. * Stencil value used for the other meshes in the scene.
  63137. */
  63138. static NormalMeshStencilReference: number;
  63139. /**
  63140. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63141. */
  63142. innerGlow: boolean;
  63143. /**
  63144. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63145. */
  63146. outerGlow: boolean;
  63147. /**
  63148. * Specifies the horizontal size of the blur.
  63149. */
  63150. set blurHorizontalSize(value: number);
  63151. /**
  63152. * Specifies the vertical size of the blur.
  63153. */
  63154. set blurVerticalSize(value: number);
  63155. /**
  63156. * Gets the horizontal size of the blur.
  63157. */
  63158. get blurHorizontalSize(): number;
  63159. /**
  63160. * Gets the vertical size of the blur.
  63161. */
  63162. get blurVerticalSize(): number;
  63163. /**
  63164. * An event triggered when the highlight layer is being blurred.
  63165. */
  63166. onBeforeBlurObservable: Observable<HighlightLayer>;
  63167. /**
  63168. * An event triggered when the highlight layer has been blurred.
  63169. */
  63170. onAfterBlurObservable: Observable<HighlightLayer>;
  63171. private _instanceGlowingMeshStencilReference;
  63172. private _options;
  63173. private _downSamplePostprocess;
  63174. private _horizontalBlurPostprocess;
  63175. private _verticalBlurPostprocess;
  63176. private _blurTexture;
  63177. private _meshes;
  63178. private _excludedMeshes;
  63179. /**
  63180. * Instantiates a new highlight Layer and references it to the scene..
  63181. * @param name The name of the layer
  63182. * @param scene The scene to use the layer in
  63183. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63184. */
  63185. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63186. /**
  63187. * Get the effect name of the layer.
  63188. * @return The effect name
  63189. */
  63190. getEffectName(): string;
  63191. /**
  63192. * Create the merge effect. This is the shader use to blit the information back
  63193. * to the main canvas at the end of the scene rendering.
  63194. */
  63195. protected _createMergeEffect(): Effect;
  63196. /**
  63197. * Creates the render target textures and post processes used in the highlight layer.
  63198. */
  63199. protected _createTextureAndPostProcesses(): void;
  63200. /**
  63201. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63202. */
  63203. needStencil(): boolean;
  63204. /**
  63205. * Checks for the readiness of the element composing the layer.
  63206. * @param subMesh the mesh to check for
  63207. * @param useInstances specify wether or not to use instances to render the mesh
  63208. * @param emissiveTexture the associated emissive texture used to generate the glow
  63209. * @return true if ready otherwise, false
  63210. */
  63211. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63212. /**
  63213. * Implementation specific of rendering the generating effect on the main canvas.
  63214. * @param effect The effect used to render through
  63215. */
  63216. protected _internalRender(effect: Effect): void;
  63217. /**
  63218. * Returns true if the layer contains information to display, otherwise false.
  63219. */
  63220. shouldRender(): boolean;
  63221. /**
  63222. * Returns true if the mesh should render, otherwise false.
  63223. * @param mesh The mesh to render
  63224. * @returns true if it should render otherwise false
  63225. */
  63226. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63227. /**
  63228. * Returns true if the mesh can be rendered, otherwise false.
  63229. * @param mesh The mesh to render
  63230. * @param material The material used on the mesh
  63231. * @returns true if it can be rendered otherwise false
  63232. */
  63233. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63234. /**
  63235. * Adds specific effects defines.
  63236. * @param defines The defines to add specifics to.
  63237. */
  63238. protected _addCustomEffectDefines(defines: string[]): void;
  63239. /**
  63240. * Sets the required values for both the emissive texture and and the main color.
  63241. */
  63242. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63243. /**
  63244. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63245. * @param mesh The mesh to exclude from the highlight layer
  63246. */
  63247. addExcludedMesh(mesh: Mesh): void;
  63248. /**
  63249. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63250. * @param mesh The mesh to highlight
  63251. */
  63252. removeExcludedMesh(mesh: Mesh): void;
  63253. /**
  63254. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63255. * @param mesh mesh to test
  63256. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63257. */
  63258. hasMesh(mesh: AbstractMesh): boolean;
  63259. /**
  63260. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63261. * @param mesh The mesh to highlight
  63262. * @param color The color of the highlight
  63263. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63264. */
  63265. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63266. /**
  63267. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63268. * @param mesh The mesh to highlight
  63269. */
  63270. removeMesh(mesh: Mesh): void;
  63271. /**
  63272. * Remove all the meshes currently referenced in the highlight layer
  63273. */
  63274. removeAllMeshes(): void;
  63275. /**
  63276. * Force the stencil to the normal expected value for none glowing parts
  63277. */
  63278. private _defaultStencilReference;
  63279. /**
  63280. * Free any resources and references associated to a mesh.
  63281. * Internal use
  63282. * @param mesh The mesh to free.
  63283. * @hidden
  63284. */
  63285. _disposeMesh(mesh: Mesh): void;
  63286. /**
  63287. * Dispose the highlight layer and free resources.
  63288. */
  63289. dispose(): void;
  63290. /**
  63291. * Gets the class name of the effect layer
  63292. * @returns the string with the class name of the effect layer
  63293. */
  63294. getClassName(): string;
  63295. /**
  63296. * Serializes this Highlight layer
  63297. * @returns a serialized Highlight layer object
  63298. */
  63299. serialize(): any;
  63300. /**
  63301. * Creates a Highlight layer from parsed Highlight layer data
  63302. * @param parsedHightlightLayer defines the Highlight layer data
  63303. * @param scene defines the current scene
  63304. * @param rootUrl defines the root URL containing the Highlight layer information
  63305. * @returns a parsed Highlight layer
  63306. */
  63307. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63308. }
  63309. }
  63310. declare module BABYLON {
  63311. interface AbstractScene {
  63312. /**
  63313. * The list of layers (background and foreground) of the scene
  63314. */
  63315. layers: Array<Layer>;
  63316. }
  63317. /**
  63318. * Defines the layer scene component responsible to manage any layers
  63319. * in a given scene.
  63320. */
  63321. export class LayerSceneComponent implements ISceneComponent {
  63322. /**
  63323. * The component name helpfull to identify the component in the list of scene components.
  63324. */
  63325. readonly name: string;
  63326. /**
  63327. * The scene the component belongs to.
  63328. */
  63329. scene: Scene;
  63330. private _engine;
  63331. /**
  63332. * Creates a new instance of the component for the given scene
  63333. * @param scene Defines the scene to register the component in
  63334. */
  63335. constructor(scene: Scene);
  63336. /**
  63337. * Registers the component in a given scene
  63338. */
  63339. register(): void;
  63340. /**
  63341. * Rebuilds the elements related to this component in case of
  63342. * context lost for instance.
  63343. */
  63344. rebuild(): void;
  63345. /**
  63346. * Disposes the component and the associated ressources.
  63347. */
  63348. dispose(): void;
  63349. private _draw;
  63350. private _drawCameraPredicate;
  63351. private _drawCameraBackground;
  63352. private _drawCameraForeground;
  63353. private _drawRenderTargetPredicate;
  63354. private _drawRenderTargetBackground;
  63355. private _drawRenderTargetForeground;
  63356. /**
  63357. * Adds all the elements from the container to the scene
  63358. * @param container the container holding the elements
  63359. */
  63360. addFromContainer(container: AbstractScene): void;
  63361. /**
  63362. * Removes all the elements in the container from the scene
  63363. * @param container contains the elements to remove
  63364. * @param dispose if the removed element should be disposed (default: false)
  63365. */
  63366. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63367. }
  63368. }
  63369. declare module BABYLON {
  63370. /** @hidden */
  63371. export var layerPixelShader: {
  63372. name: string;
  63373. shader: string;
  63374. };
  63375. }
  63376. declare module BABYLON {
  63377. /** @hidden */
  63378. export var layerVertexShader: {
  63379. name: string;
  63380. shader: string;
  63381. };
  63382. }
  63383. declare module BABYLON {
  63384. /**
  63385. * This represents a full screen 2d layer.
  63386. * This can be useful to display a picture in the background of your scene for instance.
  63387. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63388. */
  63389. export class Layer {
  63390. /**
  63391. * Define the name of the layer.
  63392. */
  63393. name: string;
  63394. /**
  63395. * Define the texture the layer should display.
  63396. */
  63397. texture: Nullable<Texture>;
  63398. /**
  63399. * Is the layer in background or foreground.
  63400. */
  63401. isBackground: boolean;
  63402. /**
  63403. * Define the color of the layer (instead of texture).
  63404. */
  63405. color: Color4;
  63406. /**
  63407. * Define the scale of the layer in order to zoom in out of the texture.
  63408. */
  63409. scale: Vector2;
  63410. /**
  63411. * Define an offset for the layer in order to shift the texture.
  63412. */
  63413. offset: Vector2;
  63414. /**
  63415. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63416. */
  63417. alphaBlendingMode: number;
  63418. /**
  63419. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63420. * Alpha test will not mix with the background color in case of transparency.
  63421. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63422. */
  63423. alphaTest: boolean;
  63424. /**
  63425. * Define a mask to restrict the layer to only some of the scene cameras.
  63426. */
  63427. layerMask: number;
  63428. /**
  63429. * Define the list of render target the layer is visible into.
  63430. */
  63431. renderTargetTextures: RenderTargetTexture[];
  63432. /**
  63433. * Define if the layer is only used in renderTarget or if it also
  63434. * renders in the main frame buffer of the canvas.
  63435. */
  63436. renderOnlyInRenderTargetTextures: boolean;
  63437. private _scene;
  63438. private _vertexBuffers;
  63439. private _indexBuffer;
  63440. private _effect;
  63441. private _previousDefines;
  63442. /**
  63443. * An event triggered when the layer is disposed.
  63444. */
  63445. onDisposeObservable: Observable<Layer>;
  63446. private _onDisposeObserver;
  63447. /**
  63448. * Back compatibility with callback before the onDisposeObservable existed.
  63449. * The set callback will be triggered when the layer has been disposed.
  63450. */
  63451. set onDispose(callback: () => void);
  63452. /**
  63453. * An event triggered before rendering the scene
  63454. */
  63455. onBeforeRenderObservable: Observable<Layer>;
  63456. private _onBeforeRenderObserver;
  63457. /**
  63458. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63459. * The set callback will be triggered just before rendering the layer.
  63460. */
  63461. set onBeforeRender(callback: () => void);
  63462. /**
  63463. * An event triggered after rendering the scene
  63464. */
  63465. onAfterRenderObservable: Observable<Layer>;
  63466. private _onAfterRenderObserver;
  63467. /**
  63468. * Back compatibility with callback before the onAfterRenderObservable existed.
  63469. * The set callback will be triggered just after rendering the layer.
  63470. */
  63471. set onAfterRender(callback: () => void);
  63472. /**
  63473. * Instantiates a new layer.
  63474. * This represents a full screen 2d layer.
  63475. * This can be useful to display a picture in the background of your scene for instance.
  63476. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63477. * @param name Define the name of the layer in the scene
  63478. * @param imgUrl Define the url of the texture to display in the layer
  63479. * @param scene Define the scene the layer belongs to
  63480. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63481. * @param color Defines a color for the layer
  63482. */
  63483. constructor(
  63484. /**
  63485. * Define the name of the layer.
  63486. */
  63487. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63488. private _createIndexBuffer;
  63489. /** @hidden */
  63490. _rebuild(): void;
  63491. /**
  63492. * Renders the layer in the scene.
  63493. */
  63494. render(): void;
  63495. /**
  63496. * Disposes and releases the associated ressources.
  63497. */
  63498. dispose(): void;
  63499. }
  63500. }
  63501. declare module BABYLON {
  63502. /** @hidden */
  63503. export var lensFlarePixelShader: {
  63504. name: string;
  63505. shader: string;
  63506. };
  63507. }
  63508. declare module BABYLON {
  63509. /** @hidden */
  63510. export var lensFlareVertexShader: {
  63511. name: string;
  63512. shader: string;
  63513. };
  63514. }
  63515. declare module BABYLON {
  63516. /**
  63517. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63518. * It is usually composed of several `lensFlare`.
  63519. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63520. */
  63521. export class LensFlareSystem {
  63522. /**
  63523. * Define the name of the lens flare system
  63524. */
  63525. name: string;
  63526. /**
  63527. * List of lens flares used in this system.
  63528. */
  63529. lensFlares: LensFlare[];
  63530. /**
  63531. * Define a limit from the border the lens flare can be visible.
  63532. */
  63533. borderLimit: number;
  63534. /**
  63535. * Define a viewport border we do not want to see the lens flare in.
  63536. */
  63537. viewportBorder: number;
  63538. /**
  63539. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63540. */
  63541. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63542. /**
  63543. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63544. */
  63545. layerMask: number;
  63546. /**
  63547. * Define the id of the lens flare system in the scene.
  63548. * (equal to name by default)
  63549. */
  63550. id: string;
  63551. private _scene;
  63552. private _emitter;
  63553. private _vertexBuffers;
  63554. private _indexBuffer;
  63555. private _effect;
  63556. private _positionX;
  63557. private _positionY;
  63558. private _isEnabled;
  63559. /** @hidden */
  63560. static _SceneComponentInitialization: (scene: Scene) => void;
  63561. /**
  63562. * Instantiates a lens flare system.
  63563. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63564. * It is usually composed of several `lensFlare`.
  63565. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63566. * @param name Define the name of the lens flare system in the scene
  63567. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63568. * @param scene Define the scene the lens flare system belongs to
  63569. */
  63570. constructor(
  63571. /**
  63572. * Define the name of the lens flare system
  63573. */
  63574. name: string, emitter: any, scene: Scene);
  63575. /**
  63576. * Define if the lens flare system is enabled.
  63577. */
  63578. get isEnabled(): boolean;
  63579. set isEnabled(value: boolean);
  63580. /**
  63581. * Get the scene the effects belongs to.
  63582. * @returns the scene holding the lens flare system
  63583. */
  63584. getScene(): Scene;
  63585. /**
  63586. * Get the emitter of the lens flare system.
  63587. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63588. * @returns the emitter of the lens flare system
  63589. */
  63590. getEmitter(): any;
  63591. /**
  63592. * Set the emitter of the lens flare system.
  63593. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63594. * @param newEmitter Define the new emitter of the system
  63595. */
  63596. setEmitter(newEmitter: any): void;
  63597. /**
  63598. * Get the lens flare system emitter position.
  63599. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63600. * @returns the position
  63601. */
  63602. getEmitterPosition(): Vector3;
  63603. /**
  63604. * @hidden
  63605. */
  63606. computeEffectivePosition(globalViewport: Viewport): boolean;
  63607. /** @hidden */
  63608. _isVisible(): boolean;
  63609. /**
  63610. * @hidden
  63611. */
  63612. render(): boolean;
  63613. /**
  63614. * Dispose and release the lens flare with its associated resources.
  63615. */
  63616. dispose(): void;
  63617. /**
  63618. * Parse a lens flare system from a JSON repressentation
  63619. * @param parsedLensFlareSystem Define the JSON to parse
  63620. * @param scene Define the scene the parsed system should be instantiated in
  63621. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63622. * @returns the parsed system
  63623. */
  63624. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63625. /**
  63626. * Serialize the current Lens Flare System into a JSON representation.
  63627. * @returns the serialized JSON
  63628. */
  63629. serialize(): any;
  63630. }
  63631. }
  63632. declare module BABYLON {
  63633. /**
  63634. * This represents one of the lens effect in a `lensFlareSystem`.
  63635. * It controls one of the indiviual texture used in the effect.
  63636. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63637. */
  63638. export class LensFlare {
  63639. /**
  63640. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63641. */
  63642. size: number;
  63643. /**
  63644. * 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.
  63645. */
  63646. position: number;
  63647. /**
  63648. * Define the lens color.
  63649. */
  63650. color: Color3;
  63651. /**
  63652. * Define the lens texture.
  63653. */
  63654. texture: Nullable<Texture>;
  63655. /**
  63656. * Define the alpha mode to render this particular lens.
  63657. */
  63658. alphaMode: number;
  63659. private _system;
  63660. /**
  63661. * Creates a new Lens Flare.
  63662. * This represents one of the lens effect in a `lensFlareSystem`.
  63663. * It controls one of the indiviual texture used in the effect.
  63664. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63665. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63666. * @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.
  63667. * @param color Define the lens color
  63668. * @param imgUrl Define the lens texture url
  63669. * @param system Define the `lensFlareSystem` this flare is part of
  63670. * @returns The newly created Lens Flare
  63671. */
  63672. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63673. /**
  63674. * Instantiates a new Lens Flare.
  63675. * This represents one of the lens effect in a `lensFlareSystem`.
  63676. * It controls one of the indiviual texture used in the effect.
  63677. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63678. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63679. * @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.
  63680. * @param color Define the lens color
  63681. * @param imgUrl Define the lens texture url
  63682. * @param system Define the `lensFlareSystem` this flare is part of
  63683. */
  63684. constructor(
  63685. /**
  63686. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63687. */
  63688. size: number,
  63689. /**
  63690. * 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.
  63691. */
  63692. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63693. /**
  63694. * Dispose and release the lens flare with its associated resources.
  63695. */
  63696. dispose(): void;
  63697. }
  63698. }
  63699. declare module BABYLON {
  63700. interface AbstractScene {
  63701. /**
  63702. * The list of lens flare system added to the scene
  63703. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63704. */
  63705. lensFlareSystems: Array<LensFlareSystem>;
  63706. /**
  63707. * Removes the given lens flare system from this scene.
  63708. * @param toRemove The lens flare system to remove
  63709. * @returns The index of the removed lens flare system
  63710. */
  63711. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63712. /**
  63713. * Adds the given lens flare system to this scene
  63714. * @param newLensFlareSystem The lens flare system to add
  63715. */
  63716. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63717. /**
  63718. * Gets a lens flare system using its name
  63719. * @param name defines the name to look for
  63720. * @returns the lens flare system or null if not found
  63721. */
  63722. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63723. /**
  63724. * Gets a lens flare system using its id
  63725. * @param id defines the id to look for
  63726. * @returns the lens flare system or null if not found
  63727. */
  63728. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63729. }
  63730. /**
  63731. * Defines the lens flare scene component responsible to manage any lens flares
  63732. * in a given scene.
  63733. */
  63734. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63735. /**
  63736. * The component name helpfull to identify the component in the list of scene components.
  63737. */
  63738. readonly name: string;
  63739. /**
  63740. * The scene the component belongs to.
  63741. */
  63742. scene: Scene;
  63743. /**
  63744. * Creates a new instance of the component for the given scene
  63745. * @param scene Defines the scene to register the component in
  63746. */
  63747. constructor(scene: Scene);
  63748. /**
  63749. * Registers the component in a given scene
  63750. */
  63751. register(): void;
  63752. /**
  63753. * Rebuilds the elements related to this component in case of
  63754. * context lost for instance.
  63755. */
  63756. rebuild(): void;
  63757. /**
  63758. * Adds all the elements from the container to the scene
  63759. * @param container the container holding the elements
  63760. */
  63761. addFromContainer(container: AbstractScene): void;
  63762. /**
  63763. * Removes all the elements in the container from the scene
  63764. * @param container contains the elements to remove
  63765. * @param dispose if the removed element should be disposed (default: false)
  63766. */
  63767. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63768. /**
  63769. * Serializes the component data to the specified json object
  63770. * @param serializationObject The object to serialize to
  63771. */
  63772. serialize(serializationObject: any): void;
  63773. /**
  63774. * Disposes the component and the associated ressources.
  63775. */
  63776. dispose(): void;
  63777. private _draw;
  63778. }
  63779. }
  63780. declare module BABYLON {
  63781. /** @hidden */
  63782. export var depthPixelShader: {
  63783. name: string;
  63784. shader: string;
  63785. };
  63786. }
  63787. declare module BABYLON {
  63788. /** @hidden */
  63789. export var depthVertexShader: {
  63790. name: string;
  63791. shader: string;
  63792. };
  63793. }
  63794. declare module BABYLON {
  63795. /**
  63796. * This represents a depth renderer in Babylon.
  63797. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63798. */
  63799. export class DepthRenderer {
  63800. private _scene;
  63801. private _depthMap;
  63802. private _effect;
  63803. private readonly _storeNonLinearDepth;
  63804. private readonly _clearColor;
  63805. /** Get if the depth renderer is using packed depth or not */
  63806. readonly isPacked: boolean;
  63807. private _cachedDefines;
  63808. private _camera;
  63809. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63810. enabled: boolean;
  63811. /**
  63812. * Specifiess that the depth renderer will only be used within
  63813. * the camera it is created for.
  63814. * This can help forcing its rendering during the camera processing.
  63815. */
  63816. useOnlyInActiveCamera: boolean;
  63817. /** @hidden */
  63818. static _SceneComponentInitialization: (scene: Scene) => void;
  63819. /**
  63820. * Instantiates a depth renderer
  63821. * @param scene The scene the renderer belongs to
  63822. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63823. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63824. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63825. */
  63826. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63827. /**
  63828. * Creates the depth rendering effect and checks if the effect is ready.
  63829. * @param subMesh The submesh to be used to render the depth map of
  63830. * @param useInstances If multiple world instances should be used
  63831. * @returns if the depth renderer is ready to render the depth map
  63832. */
  63833. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63834. /**
  63835. * Gets the texture which the depth map will be written to.
  63836. * @returns The depth map texture
  63837. */
  63838. getDepthMap(): RenderTargetTexture;
  63839. /**
  63840. * Disposes of the depth renderer.
  63841. */
  63842. dispose(): void;
  63843. }
  63844. }
  63845. declare module BABYLON {
  63846. /** @hidden */
  63847. export var minmaxReduxPixelShader: {
  63848. name: string;
  63849. shader: string;
  63850. };
  63851. }
  63852. declare module BABYLON {
  63853. /**
  63854. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63855. * and maximum values from all values of the texture.
  63856. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63857. * The source values are read from the red channel of the texture.
  63858. */
  63859. export class MinMaxReducer {
  63860. /**
  63861. * Observable triggered when the computation has been performed
  63862. */
  63863. onAfterReductionPerformed: Observable<{
  63864. min: number;
  63865. max: number;
  63866. }>;
  63867. protected _camera: Camera;
  63868. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63869. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63870. protected _postProcessManager: PostProcessManager;
  63871. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63872. protected _forceFullscreenViewport: boolean;
  63873. /**
  63874. * Creates a min/max reducer
  63875. * @param camera The camera to use for the post processes
  63876. */
  63877. constructor(camera: Camera);
  63878. /**
  63879. * Gets the texture used to read the values from.
  63880. */
  63881. get sourceTexture(): Nullable<RenderTargetTexture>;
  63882. /**
  63883. * Sets the source texture to read the values from.
  63884. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63885. * because in such textures '1' value must not be taken into account to compute the maximum
  63886. * as this value is used to clear the texture.
  63887. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63888. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63889. * @param depthRedux Indicates if the texture is a depth texture or not
  63890. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63891. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63892. */
  63893. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63894. /**
  63895. * Defines the refresh rate of the computation.
  63896. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63897. */
  63898. get refreshRate(): number;
  63899. set refreshRate(value: number);
  63900. protected _activated: boolean;
  63901. /**
  63902. * Gets the activation status of the reducer
  63903. */
  63904. get activated(): boolean;
  63905. /**
  63906. * Activates the reduction computation.
  63907. * When activated, the observers registered in onAfterReductionPerformed are
  63908. * called after the compuation is performed
  63909. */
  63910. activate(): void;
  63911. /**
  63912. * Deactivates the reduction computation.
  63913. */
  63914. deactivate(): void;
  63915. /**
  63916. * Disposes the min/max reducer
  63917. * @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.
  63918. */
  63919. dispose(disposeAll?: boolean): void;
  63920. }
  63921. }
  63922. declare module BABYLON {
  63923. /**
  63924. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63925. */
  63926. export class DepthReducer extends MinMaxReducer {
  63927. private _depthRenderer;
  63928. private _depthRendererId;
  63929. /**
  63930. * Gets the depth renderer used for the computation.
  63931. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63932. */
  63933. get depthRenderer(): Nullable<DepthRenderer>;
  63934. /**
  63935. * Creates a depth reducer
  63936. * @param camera The camera used to render the depth texture
  63937. */
  63938. constructor(camera: Camera);
  63939. /**
  63940. * Sets the depth renderer to use to generate the depth map
  63941. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63942. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63943. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63944. */
  63945. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63946. /** @hidden */
  63947. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63948. /**
  63949. * Activates the reduction computation.
  63950. * When activated, the observers registered in onAfterReductionPerformed are
  63951. * called after the compuation is performed
  63952. */
  63953. activate(): void;
  63954. /**
  63955. * Deactivates the reduction computation.
  63956. */
  63957. deactivate(): void;
  63958. /**
  63959. * Disposes the depth reducer
  63960. * @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.
  63961. */
  63962. dispose(disposeAll?: boolean): void;
  63963. }
  63964. }
  63965. declare module BABYLON {
  63966. /**
  63967. * A CSM implementation allowing casting shadows on large scenes.
  63968. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63969. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63970. */
  63971. export class CascadedShadowGenerator extends ShadowGenerator {
  63972. private static readonly frustumCornersNDCSpace;
  63973. /**
  63974. * Name of the CSM class
  63975. */
  63976. static CLASSNAME: string;
  63977. /**
  63978. * Defines the default number of cascades used by the CSM.
  63979. */
  63980. static readonly DEFAULT_CASCADES_COUNT: number;
  63981. /**
  63982. * Defines the minimum number of cascades used by the CSM.
  63983. */
  63984. static readonly MIN_CASCADES_COUNT: number;
  63985. /**
  63986. * Defines the maximum number of cascades used by the CSM.
  63987. */
  63988. static readonly MAX_CASCADES_COUNT: number;
  63989. protected _validateFilter(filter: number): number;
  63990. /**
  63991. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63992. */
  63993. penumbraDarkness: number;
  63994. private _numCascades;
  63995. /**
  63996. * Gets or set the number of cascades used by the CSM.
  63997. */
  63998. get numCascades(): number;
  63999. set numCascades(value: number);
  64000. /**
  64001. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64002. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64003. */
  64004. stabilizeCascades: boolean;
  64005. private _freezeShadowCastersBoundingInfo;
  64006. private _freezeShadowCastersBoundingInfoObservable;
  64007. /**
  64008. * Enables or disables the shadow casters bounding info computation.
  64009. * If your shadow casters don't move, you can disable this feature.
  64010. * If it is enabled, the bounding box computation is done every frame.
  64011. */
  64012. get freezeShadowCastersBoundingInfo(): boolean;
  64013. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64014. private _scbiMin;
  64015. private _scbiMax;
  64016. protected _computeShadowCastersBoundingInfo(): void;
  64017. protected _shadowCastersBoundingInfo: BoundingInfo;
  64018. /**
  64019. * Gets or sets the shadow casters bounding info.
  64020. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64021. * so that the system won't overwrite the bounds you provide
  64022. */
  64023. get shadowCastersBoundingInfo(): BoundingInfo;
  64024. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64025. protected _breaksAreDirty: boolean;
  64026. protected _minDistance: number;
  64027. protected _maxDistance: number;
  64028. /**
  64029. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64030. *
  64031. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64032. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64033. * @param min minimal distance for the breaks (default to 0.)
  64034. * @param max maximal distance for the breaks (default to 1.)
  64035. */
  64036. setMinMaxDistance(min: number, max: number): void;
  64037. /** Gets the minimal distance used in the cascade break computation */
  64038. get minDistance(): number;
  64039. /** Gets the maximal distance used in the cascade break computation */
  64040. get maxDistance(): number;
  64041. /**
  64042. * Gets the class name of that object
  64043. * @returns "CascadedShadowGenerator"
  64044. */
  64045. getClassName(): string;
  64046. private _cascadeMinExtents;
  64047. private _cascadeMaxExtents;
  64048. /**
  64049. * Gets a cascade minimum extents
  64050. * @param cascadeIndex index of the cascade
  64051. * @returns the minimum cascade extents
  64052. */
  64053. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64054. /**
  64055. * Gets a cascade maximum extents
  64056. * @param cascadeIndex index of the cascade
  64057. * @returns the maximum cascade extents
  64058. */
  64059. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64060. private _cascades;
  64061. private _currentLayer;
  64062. private _viewSpaceFrustumsZ;
  64063. private _viewMatrices;
  64064. private _projectionMatrices;
  64065. private _transformMatrices;
  64066. private _transformMatricesAsArray;
  64067. private _frustumLengths;
  64068. private _lightSizeUVCorrection;
  64069. private _depthCorrection;
  64070. private _frustumCornersWorldSpace;
  64071. private _frustumCenter;
  64072. private _shadowCameraPos;
  64073. private _shadowMaxZ;
  64074. /**
  64075. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64076. * It defaults to camera.maxZ
  64077. */
  64078. get shadowMaxZ(): number;
  64079. /**
  64080. * Sets the shadow max z distance.
  64081. */
  64082. set shadowMaxZ(value: number);
  64083. protected _debug: boolean;
  64084. /**
  64085. * Gets or sets the debug flag.
  64086. * When enabled, the cascades are materialized by different colors on the screen.
  64087. */
  64088. get debug(): boolean;
  64089. set debug(dbg: boolean);
  64090. private _depthClamp;
  64091. /**
  64092. * Gets or sets the depth clamping value.
  64093. *
  64094. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64095. * to account for the shadow casters far away.
  64096. *
  64097. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64098. */
  64099. get depthClamp(): boolean;
  64100. set depthClamp(value: boolean);
  64101. private _cascadeBlendPercentage;
  64102. /**
  64103. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64104. * It defaults to 0.1 (10% blending).
  64105. */
  64106. get cascadeBlendPercentage(): number;
  64107. set cascadeBlendPercentage(value: number);
  64108. private _lambda;
  64109. /**
  64110. * Gets or set the lambda parameter.
  64111. * This parameter is used to split the camera frustum and create the cascades.
  64112. * 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.
  64113. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64114. */
  64115. get lambda(): number;
  64116. set lambda(value: number);
  64117. /**
  64118. * Gets the view matrix corresponding to a given cascade
  64119. * @param cascadeNum cascade to retrieve the view matrix from
  64120. * @returns the cascade view matrix
  64121. */
  64122. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64123. /**
  64124. * Gets the projection matrix corresponding to a given cascade
  64125. * @param cascadeNum cascade to retrieve the projection matrix from
  64126. * @returns the cascade projection matrix
  64127. */
  64128. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64129. /**
  64130. * Gets the transformation matrix corresponding to a given cascade
  64131. * @param cascadeNum cascade to retrieve the transformation matrix from
  64132. * @returns the cascade transformation matrix
  64133. */
  64134. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64135. private _depthRenderer;
  64136. /**
  64137. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64138. *
  64139. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64140. *
  64141. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64142. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64143. * @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
  64144. */
  64145. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64146. private _depthReducer;
  64147. private _autoCalcDepthBounds;
  64148. /**
  64149. * Gets or sets the autoCalcDepthBounds property.
  64150. *
  64151. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64152. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64153. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64154. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64155. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64156. */
  64157. get autoCalcDepthBounds(): boolean;
  64158. set autoCalcDepthBounds(value: boolean);
  64159. /**
  64160. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64161. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64162. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64163. * for setting the refresh rate on the renderer yourself!
  64164. */
  64165. get autoCalcDepthBoundsRefreshRate(): number;
  64166. set autoCalcDepthBoundsRefreshRate(value: number);
  64167. /**
  64168. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64169. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64170. * you change the camera near/far planes!
  64171. */
  64172. splitFrustum(): void;
  64173. private _splitFrustum;
  64174. private _computeMatrices;
  64175. private _computeFrustumInWorldSpace;
  64176. private _computeCascadeFrustum;
  64177. /**
  64178. * Support test.
  64179. */
  64180. static get IsSupported(): boolean;
  64181. /** @hidden */
  64182. static _SceneComponentInitialization: (scene: Scene) => void;
  64183. /**
  64184. * Creates a Cascaded Shadow Generator object.
  64185. * A ShadowGenerator is the required tool to use the shadows.
  64186. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64187. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64188. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64189. * @param light The directional light object generating the shadows.
  64190. * @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.
  64191. */
  64192. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64193. protected _initializeGenerator(): void;
  64194. protected _createTargetRenderTexture(): void;
  64195. protected _initializeShadowMap(): void;
  64196. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64197. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64198. /**
  64199. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64200. * @param defines Defines of the material we want to update
  64201. * @param lightIndex Index of the light in the enabled light list of the material
  64202. */
  64203. prepareDefines(defines: any, lightIndex: number): void;
  64204. /**
  64205. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64206. * defined in the generator but impacting the effect).
  64207. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64208. * @param effect The effect we are binfing the information for
  64209. */
  64210. bindShadowLight(lightIndex: string, effect: Effect): void;
  64211. /**
  64212. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64213. * (eq to view projection * shadow projection matrices)
  64214. * @returns The transform matrix used to create the shadow map
  64215. */
  64216. getTransformMatrix(): Matrix;
  64217. /**
  64218. * Disposes the ShadowGenerator.
  64219. * Returns nothing.
  64220. */
  64221. dispose(): void;
  64222. /**
  64223. * Serializes the shadow generator setup to a json object.
  64224. * @returns The serialized JSON object
  64225. */
  64226. serialize(): any;
  64227. /**
  64228. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64229. * @param parsedShadowGenerator The JSON object to parse
  64230. * @param scene The scene to create the shadow map for
  64231. * @returns The parsed shadow generator
  64232. */
  64233. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64234. }
  64235. }
  64236. declare module BABYLON {
  64237. /**
  64238. * Defines the shadow generator component responsible to manage any shadow generators
  64239. * in a given scene.
  64240. */
  64241. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64242. /**
  64243. * The component name helpfull to identify the component in the list of scene components.
  64244. */
  64245. readonly name: string;
  64246. /**
  64247. * The scene the component belongs to.
  64248. */
  64249. scene: Scene;
  64250. /**
  64251. * Creates a new instance of the component for the given scene
  64252. * @param scene Defines the scene to register the component in
  64253. */
  64254. constructor(scene: Scene);
  64255. /**
  64256. * Registers the component in a given scene
  64257. */
  64258. register(): void;
  64259. /**
  64260. * Rebuilds the elements related to this component in case of
  64261. * context lost for instance.
  64262. */
  64263. rebuild(): void;
  64264. /**
  64265. * Serializes the component data to the specified json object
  64266. * @param serializationObject The object to serialize to
  64267. */
  64268. serialize(serializationObject: any): void;
  64269. /**
  64270. * Adds all the elements from the container to the scene
  64271. * @param container the container holding the elements
  64272. */
  64273. addFromContainer(container: AbstractScene): void;
  64274. /**
  64275. * Removes all the elements in the container from the scene
  64276. * @param container contains the elements to remove
  64277. * @param dispose if the removed element should be disposed (default: false)
  64278. */
  64279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64280. /**
  64281. * Rebuilds the elements related to this component in case of
  64282. * context lost for instance.
  64283. */
  64284. dispose(): void;
  64285. private _gatherRenderTargets;
  64286. }
  64287. }
  64288. declare module BABYLON {
  64289. /**
  64290. * A point light is a light defined by an unique point in world space.
  64291. * The light is emitted in every direction from this point.
  64292. * A good example of a point light is a standard light bulb.
  64293. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64294. */
  64295. export class PointLight extends ShadowLight {
  64296. private _shadowAngle;
  64297. /**
  64298. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64299. * This specifies what angle the shadow will use to be created.
  64300. *
  64301. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64302. */
  64303. get shadowAngle(): number;
  64304. /**
  64305. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64306. * This specifies what angle the shadow will use to be created.
  64307. *
  64308. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64309. */
  64310. set shadowAngle(value: number);
  64311. /**
  64312. * Gets the direction if it has been set.
  64313. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64314. */
  64315. get direction(): Vector3;
  64316. /**
  64317. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64318. */
  64319. set direction(value: Vector3);
  64320. /**
  64321. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64322. * A PointLight emits the light in every direction.
  64323. * It can cast shadows.
  64324. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64325. * ```javascript
  64326. * var pointLight = new PointLight("pl", camera.position, scene);
  64327. * ```
  64328. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64329. * @param name The light friendly name
  64330. * @param position The position of the point light in the scene
  64331. * @param scene The scene the lights belongs to
  64332. */
  64333. constructor(name: string, position: Vector3, scene: Scene);
  64334. /**
  64335. * Returns the string "PointLight"
  64336. * @returns the class name
  64337. */
  64338. getClassName(): string;
  64339. /**
  64340. * Returns the integer 0.
  64341. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64342. */
  64343. getTypeID(): number;
  64344. /**
  64345. * Specifies wether or not the shadowmap should be a cube texture.
  64346. * @returns true if the shadowmap needs to be a cube texture.
  64347. */
  64348. needCube(): boolean;
  64349. /**
  64350. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64351. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64352. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64353. */
  64354. getShadowDirection(faceIndex?: number): Vector3;
  64355. /**
  64356. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64357. * - fov = PI / 2
  64358. * - aspect ratio : 1.0
  64359. * - z-near and far equal to the active camera minZ and maxZ.
  64360. * Returns the PointLight.
  64361. */
  64362. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64363. protected _buildUniformLayout(): void;
  64364. /**
  64365. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64366. * @param effect The effect to update
  64367. * @param lightIndex The index of the light in the effect to update
  64368. * @returns The point light
  64369. */
  64370. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64371. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64372. /**
  64373. * Prepares the list of defines specific to the light type.
  64374. * @param defines the list of defines
  64375. * @param lightIndex defines the index of the light for the effect
  64376. */
  64377. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64378. }
  64379. }
  64380. declare module BABYLON {
  64381. /**
  64382. * Header information of HDR texture files.
  64383. */
  64384. export interface HDRInfo {
  64385. /**
  64386. * The height of the texture in pixels.
  64387. */
  64388. height: number;
  64389. /**
  64390. * The width of the texture in pixels.
  64391. */
  64392. width: number;
  64393. /**
  64394. * The index of the beginning of the data in the binary file.
  64395. */
  64396. dataPosition: number;
  64397. }
  64398. /**
  64399. * This groups tools to convert HDR texture to native colors array.
  64400. */
  64401. export class HDRTools {
  64402. private static Ldexp;
  64403. private static Rgbe2float;
  64404. private static readStringLine;
  64405. /**
  64406. * Reads header information from an RGBE texture stored in a native array.
  64407. * More information on this format are available here:
  64408. * https://en.wikipedia.org/wiki/RGBE_image_format
  64409. *
  64410. * @param uint8array The binary file stored in native array.
  64411. * @return The header information.
  64412. */
  64413. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64414. /**
  64415. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64416. * This RGBE texture needs to store the information as a panorama.
  64417. *
  64418. * More information on this format are available here:
  64419. * https://en.wikipedia.org/wiki/RGBE_image_format
  64420. *
  64421. * @param buffer The binary file stored in an array buffer.
  64422. * @param size The expected size of the extracted cubemap.
  64423. * @return The Cube Map information.
  64424. */
  64425. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64426. /**
  64427. * Returns the pixels data extracted from an RGBE texture.
  64428. * This pixels will be stored left to right up to down in the R G B order in one array.
  64429. *
  64430. * More information on this format are available here:
  64431. * https://en.wikipedia.org/wiki/RGBE_image_format
  64432. *
  64433. * @param uint8array The binary file stored in an array buffer.
  64434. * @param hdrInfo The header information of the file.
  64435. * @return The pixels data in RGB right to left up to down order.
  64436. */
  64437. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64438. private static RGBE_ReadPixels_RLE;
  64439. private static RGBE_ReadPixels_NOT_RLE;
  64440. }
  64441. }
  64442. declare module BABYLON {
  64443. /**
  64444. * Effect Render Options
  64445. */
  64446. export interface IEffectRendererOptions {
  64447. /**
  64448. * Defines the vertices positions.
  64449. */
  64450. positions?: number[];
  64451. /**
  64452. * Defines the indices.
  64453. */
  64454. indices?: number[];
  64455. }
  64456. /**
  64457. * Helper class to render one or more effects.
  64458. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64459. */
  64460. export class EffectRenderer {
  64461. private engine;
  64462. private static _DefaultOptions;
  64463. private _vertexBuffers;
  64464. private _indexBuffer;
  64465. private _fullscreenViewport;
  64466. /**
  64467. * Creates an effect renderer
  64468. * @param engine the engine to use for rendering
  64469. * @param options defines the options of the effect renderer
  64470. */
  64471. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64472. /**
  64473. * Sets the current viewport in normalized coordinates 0-1
  64474. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64475. */
  64476. setViewport(viewport?: Viewport): void;
  64477. /**
  64478. * Binds the embedded attributes buffer to the effect.
  64479. * @param effect Defines the effect to bind the attributes for
  64480. */
  64481. bindBuffers(effect: Effect): void;
  64482. /**
  64483. * Sets the current effect wrapper to use during draw.
  64484. * The effect needs to be ready before calling this api.
  64485. * This also sets the default full screen position attribute.
  64486. * @param effectWrapper Defines the effect to draw with
  64487. */
  64488. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64489. /**
  64490. * Restores engine states
  64491. */
  64492. restoreStates(): void;
  64493. /**
  64494. * Draws a full screen quad.
  64495. */
  64496. draw(): void;
  64497. private isRenderTargetTexture;
  64498. /**
  64499. * renders one or more effects to a specified texture
  64500. * @param effectWrapper the effect to renderer
  64501. * @param outputTexture texture to draw to, if null it will render to the screen.
  64502. */
  64503. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64504. /**
  64505. * Disposes of the effect renderer
  64506. */
  64507. dispose(): void;
  64508. }
  64509. /**
  64510. * Options to create an EffectWrapper
  64511. */
  64512. interface EffectWrapperCreationOptions {
  64513. /**
  64514. * Engine to use to create the effect
  64515. */
  64516. engine: ThinEngine;
  64517. /**
  64518. * Fragment shader for the effect
  64519. */
  64520. fragmentShader: string;
  64521. /**
  64522. * Use the shader store instead of direct source code
  64523. */
  64524. useShaderStore?: boolean;
  64525. /**
  64526. * Vertex shader for the effect
  64527. */
  64528. vertexShader?: string;
  64529. /**
  64530. * Attributes to use in the shader
  64531. */
  64532. attributeNames?: Array<string>;
  64533. /**
  64534. * Uniforms to use in the shader
  64535. */
  64536. uniformNames?: Array<string>;
  64537. /**
  64538. * Texture sampler names to use in the shader
  64539. */
  64540. samplerNames?: Array<string>;
  64541. /**
  64542. * Defines to use in the shader
  64543. */
  64544. defines?: Array<string>;
  64545. /**
  64546. * Callback when effect is compiled
  64547. */
  64548. onCompiled?: Nullable<(effect: Effect) => void>;
  64549. /**
  64550. * The friendly name of the effect displayed in Spector.
  64551. */
  64552. name?: string;
  64553. }
  64554. /**
  64555. * Wraps an effect to be used for rendering
  64556. */
  64557. export class EffectWrapper {
  64558. /**
  64559. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64560. */
  64561. onApplyObservable: Observable<{}>;
  64562. /**
  64563. * The underlying effect
  64564. */
  64565. effect: Effect;
  64566. /**
  64567. * Creates an effect to be renderer
  64568. * @param creationOptions options to create the effect
  64569. */
  64570. constructor(creationOptions: EffectWrapperCreationOptions);
  64571. /**
  64572. * Disposes of the effect wrapper
  64573. */
  64574. dispose(): void;
  64575. }
  64576. }
  64577. declare module BABYLON {
  64578. /** @hidden */
  64579. export var hdrFilteringVertexShader: {
  64580. name: string;
  64581. shader: string;
  64582. };
  64583. }
  64584. declare module BABYLON {
  64585. /** @hidden */
  64586. export var hdrFilteringPixelShader: {
  64587. name: string;
  64588. shader: string;
  64589. };
  64590. }
  64591. declare module BABYLON {
  64592. /**
  64593. * Options for texture filtering
  64594. */
  64595. interface IHDRFilteringOptions {
  64596. /**
  64597. * Scales pixel intensity for the input HDR map.
  64598. */
  64599. hdrScale?: number;
  64600. /**
  64601. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64602. */
  64603. quality?: number;
  64604. }
  64605. /**
  64606. * Filters HDR maps to get correct renderings of PBR reflections
  64607. */
  64608. export class HDRFiltering {
  64609. private _engine;
  64610. private _effectRenderer;
  64611. private _effectWrapper;
  64612. private _lodGenerationOffset;
  64613. private _lodGenerationScale;
  64614. /**
  64615. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64616. * you care about baking speed.
  64617. */
  64618. quality: number;
  64619. /**
  64620. * Scales pixel intensity for the input HDR map.
  64621. */
  64622. hdrScale: number;
  64623. /**
  64624. * Instantiates HDR filter for reflection maps
  64625. *
  64626. * @param engine Thin engine
  64627. * @param options Options
  64628. */
  64629. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64630. private _createRenderTarget;
  64631. private _prefilterInternal;
  64632. private _createEffect;
  64633. /**
  64634. * Get a value indicating if the filter is ready to be used
  64635. * @param texture Texture to filter
  64636. * @returns true if the filter is ready
  64637. */
  64638. isReady(texture: BaseTexture): boolean;
  64639. /**
  64640. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64641. * Prefiltering will be invoked at the end of next rendering pass.
  64642. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64643. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64644. * @param texture Texture to filter
  64645. * @param onFinished Callback when filtering is done
  64646. * @return Promise called when prefiltering is done
  64647. */
  64648. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  64649. }
  64650. }
  64651. declare module BABYLON {
  64652. /**
  64653. * This represents a texture coming from an HDR input.
  64654. *
  64655. * The only supported format is currently panorama picture stored in RGBE format.
  64656. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64657. */
  64658. export class HDRCubeTexture extends BaseTexture {
  64659. private static _facesMapping;
  64660. private _generateHarmonics;
  64661. private _noMipmap;
  64662. private _prefilterOnLoad;
  64663. private _textureMatrix;
  64664. private _size;
  64665. private _onLoad;
  64666. private _onError;
  64667. /**
  64668. * The texture URL.
  64669. */
  64670. url: string;
  64671. protected _isBlocking: boolean;
  64672. /**
  64673. * Sets wether or not the texture is blocking during loading.
  64674. */
  64675. set isBlocking(value: boolean);
  64676. /**
  64677. * Gets wether or not the texture is blocking during loading.
  64678. */
  64679. get isBlocking(): boolean;
  64680. protected _rotationY: number;
  64681. /**
  64682. * Sets texture matrix rotation angle around Y axis in radians.
  64683. */
  64684. set rotationY(value: number);
  64685. /**
  64686. * Gets texture matrix rotation angle around Y axis radians.
  64687. */
  64688. get rotationY(): number;
  64689. /**
  64690. * Gets or sets the center of the bounding box associated with the cube texture
  64691. * It must define where the camera used to render the texture was set
  64692. */
  64693. boundingBoxPosition: Vector3;
  64694. private _boundingBoxSize;
  64695. /**
  64696. * Gets or sets the size of the bounding box associated with the cube texture
  64697. * When defined, the cubemap will switch to local mode
  64698. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64699. * @example https://www.babylonjs-playground.com/#RNASML
  64700. */
  64701. set boundingBoxSize(value: Vector3);
  64702. get boundingBoxSize(): Vector3;
  64703. /**
  64704. * Instantiates an HDRTexture from the following parameters.
  64705. *
  64706. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64707. * @param sceneOrEngine The scene or engine the texture will be used in
  64708. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64709. * @param noMipmap Forces to not generate the mipmap if true
  64710. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64711. * @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)
  64712. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64713. */
  64714. 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>);
  64715. /**
  64716. * Get the current class name of the texture useful for serialization or dynamic coding.
  64717. * @returns "HDRCubeTexture"
  64718. */
  64719. getClassName(): string;
  64720. /**
  64721. * Occurs when the file is raw .hdr file.
  64722. */
  64723. private loadTexture;
  64724. clone(): HDRCubeTexture;
  64725. delayLoad(): void;
  64726. /**
  64727. * Get the texture reflection matrix used to rotate/transform the reflection.
  64728. * @returns the reflection matrix
  64729. */
  64730. getReflectionTextureMatrix(): Matrix;
  64731. /**
  64732. * Set the texture reflection matrix used to rotate/transform the reflection.
  64733. * @param value Define the reflection matrix to set
  64734. */
  64735. setReflectionTextureMatrix(value: Matrix): void;
  64736. /**
  64737. * Parses a JSON representation of an HDR Texture in order to create the texture
  64738. * @param parsedTexture Define the JSON representation
  64739. * @param scene Define the scene the texture should be created in
  64740. * @param rootUrl Define the root url in case we need to load relative dependencies
  64741. * @returns the newly created texture after parsing
  64742. */
  64743. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64744. serialize(): any;
  64745. }
  64746. }
  64747. declare module BABYLON {
  64748. /**
  64749. * Class used to control physics engine
  64750. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64751. */
  64752. export class PhysicsEngine implements IPhysicsEngine {
  64753. private _physicsPlugin;
  64754. /**
  64755. * Global value used to control the smallest number supported by the simulation
  64756. */
  64757. static Epsilon: number;
  64758. private _impostors;
  64759. private _joints;
  64760. private _subTimeStep;
  64761. /**
  64762. * Gets the gravity vector used by the simulation
  64763. */
  64764. gravity: Vector3;
  64765. /**
  64766. * Factory used to create the default physics plugin.
  64767. * @returns The default physics plugin
  64768. */
  64769. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64770. /**
  64771. * Creates a new Physics Engine
  64772. * @param gravity defines the gravity vector used by the simulation
  64773. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64774. */
  64775. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64776. /**
  64777. * Sets the gravity vector used by the simulation
  64778. * @param gravity defines the gravity vector to use
  64779. */
  64780. setGravity(gravity: Vector3): void;
  64781. /**
  64782. * Set the time step of the physics engine.
  64783. * Default is 1/60.
  64784. * To slow it down, enter 1/600 for example.
  64785. * To speed it up, 1/30
  64786. * @param newTimeStep defines the new timestep to apply to this world.
  64787. */
  64788. setTimeStep(newTimeStep?: number): void;
  64789. /**
  64790. * Get the time step of the physics engine.
  64791. * @returns the current time step
  64792. */
  64793. getTimeStep(): number;
  64794. /**
  64795. * Set the sub time step of the physics engine.
  64796. * Default is 0 meaning there is no sub steps
  64797. * To increase physics resolution precision, set a small value (like 1 ms)
  64798. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64799. */
  64800. setSubTimeStep(subTimeStep?: number): void;
  64801. /**
  64802. * Get the sub time step of the physics engine.
  64803. * @returns the current sub time step
  64804. */
  64805. getSubTimeStep(): number;
  64806. /**
  64807. * Release all resources
  64808. */
  64809. dispose(): void;
  64810. /**
  64811. * Gets the name of the current physics plugin
  64812. * @returns the name of the plugin
  64813. */
  64814. getPhysicsPluginName(): string;
  64815. /**
  64816. * Adding a new impostor for the impostor tracking.
  64817. * This will be done by the impostor itself.
  64818. * @param impostor the impostor to add
  64819. */
  64820. addImpostor(impostor: PhysicsImpostor): void;
  64821. /**
  64822. * Remove an impostor from the engine.
  64823. * This impostor and its mesh will not longer be updated by the physics engine.
  64824. * @param impostor the impostor to remove
  64825. */
  64826. removeImpostor(impostor: PhysicsImpostor): void;
  64827. /**
  64828. * Add a joint to the physics engine
  64829. * @param mainImpostor defines the main impostor to which the joint is added.
  64830. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64831. * @param joint defines the joint that will connect both impostors.
  64832. */
  64833. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64834. /**
  64835. * Removes a joint from the simulation
  64836. * @param mainImpostor defines the impostor used with the joint
  64837. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64838. * @param joint defines the joint to remove
  64839. */
  64840. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64841. /**
  64842. * Called by the scene. No need to call it.
  64843. * @param delta defines the timespam between frames
  64844. */
  64845. _step(delta: number): void;
  64846. /**
  64847. * Gets the current plugin used to run the simulation
  64848. * @returns current plugin
  64849. */
  64850. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64851. /**
  64852. * Gets the list of physic impostors
  64853. * @returns an array of PhysicsImpostor
  64854. */
  64855. getImpostors(): Array<PhysicsImpostor>;
  64856. /**
  64857. * Gets the impostor for a physics enabled object
  64858. * @param object defines the object impersonated by the impostor
  64859. * @returns the PhysicsImpostor or null if not found
  64860. */
  64861. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64862. /**
  64863. * Gets the impostor for a physics body object
  64864. * @param body defines physics body used by the impostor
  64865. * @returns the PhysicsImpostor or null if not found
  64866. */
  64867. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64868. /**
  64869. * Does a raycast in the physics world
  64870. * @param from when should the ray start?
  64871. * @param to when should the ray end?
  64872. * @returns PhysicsRaycastResult
  64873. */
  64874. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64875. }
  64876. }
  64877. declare module BABYLON {
  64878. /** @hidden */
  64879. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64880. private _useDeltaForWorldStep;
  64881. world: any;
  64882. name: string;
  64883. private _physicsMaterials;
  64884. private _fixedTimeStep;
  64885. private _cannonRaycastResult;
  64886. private _raycastResult;
  64887. private _physicsBodysToRemoveAfterStep;
  64888. private _firstFrame;
  64889. BJSCANNON: any;
  64890. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64891. setGravity(gravity: Vector3): void;
  64892. setTimeStep(timeStep: number): void;
  64893. getTimeStep(): number;
  64894. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64895. private _removeMarkedPhysicsBodiesFromWorld;
  64896. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64897. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64898. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64899. private _processChildMeshes;
  64900. removePhysicsBody(impostor: PhysicsImpostor): void;
  64901. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64902. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64903. private _addMaterial;
  64904. private _checkWithEpsilon;
  64905. private _createShape;
  64906. private _createHeightmap;
  64907. private _minus90X;
  64908. private _plus90X;
  64909. private _tmpPosition;
  64910. private _tmpDeltaPosition;
  64911. private _tmpUnityRotation;
  64912. private _updatePhysicsBodyTransformation;
  64913. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64914. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64915. isSupported(): boolean;
  64916. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64917. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64918. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64919. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64920. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64921. getBodyMass(impostor: PhysicsImpostor): number;
  64922. getBodyFriction(impostor: PhysicsImpostor): number;
  64923. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64924. getBodyRestitution(impostor: PhysicsImpostor): number;
  64925. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64926. sleepBody(impostor: PhysicsImpostor): void;
  64927. wakeUpBody(impostor: PhysicsImpostor): void;
  64928. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64929. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64930. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64931. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64932. getRadius(impostor: PhysicsImpostor): number;
  64933. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64934. dispose(): void;
  64935. private _extendNamespace;
  64936. /**
  64937. * Does a raycast in the physics world
  64938. * @param from when should the ray start?
  64939. * @param to when should the ray end?
  64940. * @returns PhysicsRaycastResult
  64941. */
  64942. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64943. }
  64944. }
  64945. declare module BABYLON {
  64946. /** @hidden */
  64947. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64948. private _useDeltaForWorldStep;
  64949. world: any;
  64950. name: string;
  64951. BJSOIMO: any;
  64952. private _raycastResult;
  64953. private _fixedTimeStep;
  64954. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64955. setGravity(gravity: Vector3): void;
  64956. setTimeStep(timeStep: number): void;
  64957. getTimeStep(): number;
  64958. private _tmpImpostorsArray;
  64959. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64960. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64961. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64962. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64963. private _tmpPositionVector;
  64964. removePhysicsBody(impostor: PhysicsImpostor): void;
  64965. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64966. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64967. isSupported(): boolean;
  64968. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64969. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64970. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64971. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64972. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64973. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64974. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64975. getBodyMass(impostor: PhysicsImpostor): number;
  64976. getBodyFriction(impostor: PhysicsImpostor): number;
  64977. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64978. getBodyRestitution(impostor: PhysicsImpostor): number;
  64979. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64980. sleepBody(impostor: PhysicsImpostor): void;
  64981. wakeUpBody(impostor: PhysicsImpostor): void;
  64982. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64983. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64984. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64985. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64986. getRadius(impostor: PhysicsImpostor): number;
  64987. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64988. dispose(): void;
  64989. /**
  64990. * Does a raycast in the physics world
  64991. * @param from when should the ray start?
  64992. * @param to when should the ray end?
  64993. * @returns PhysicsRaycastResult
  64994. */
  64995. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64996. }
  64997. }
  64998. declare module BABYLON {
  64999. /**
  65000. * AmmoJS Physics plugin
  65001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65002. * @see https://github.com/kripken/ammo.js/
  65003. */
  65004. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65005. private _useDeltaForWorldStep;
  65006. /**
  65007. * Reference to the Ammo library
  65008. */
  65009. bjsAMMO: any;
  65010. /**
  65011. * Created ammoJS world which physics bodies are added to
  65012. */
  65013. world: any;
  65014. /**
  65015. * Name of the plugin
  65016. */
  65017. name: string;
  65018. private _timeStep;
  65019. private _fixedTimeStep;
  65020. private _maxSteps;
  65021. private _tmpQuaternion;
  65022. private _tmpAmmoTransform;
  65023. private _tmpAmmoQuaternion;
  65024. private _tmpAmmoConcreteContactResultCallback;
  65025. private _collisionConfiguration;
  65026. private _dispatcher;
  65027. private _overlappingPairCache;
  65028. private _solver;
  65029. private _softBodySolver;
  65030. private _tmpAmmoVectorA;
  65031. private _tmpAmmoVectorB;
  65032. private _tmpAmmoVectorC;
  65033. private _tmpAmmoVectorD;
  65034. private _tmpContactCallbackResult;
  65035. private _tmpAmmoVectorRCA;
  65036. private _tmpAmmoVectorRCB;
  65037. private _raycastResult;
  65038. private _tmpContactPoint;
  65039. private static readonly DISABLE_COLLISION_FLAG;
  65040. private static readonly KINEMATIC_FLAG;
  65041. private static readonly DISABLE_DEACTIVATION_FLAG;
  65042. /**
  65043. * Initializes the ammoJS plugin
  65044. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65045. * @param ammoInjection can be used to inject your own ammo reference
  65046. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65047. */
  65048. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65049. /**
  65050. * Sets the gravity of the physics world (m/(s^2))
  65051. * @param gravity Gravity to set
  65052. */
  65053. setGravity(gravity: Vector3): void;
  65054. /**
  65055. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65056. * @param timeStep timestep to use in seconds
  65057. */
  65058. setTimeStep(timeStep: number): void;
  65059. /**
  65060. * 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)
  65061. * @param fixedTimeStep fixedTimeStep to use in seconds
  65062. */
  65063. setFixedTimeStep(fixedTimeStep: number): void;
  65064. /**
  65065. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65066. * @param maxSteps the maximum number of steps by the physics engine per frame
  65067. */
  65068. setMaxSteps(maxSteps: number): void;
  65069. /**
  65070. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65071. * @returns the current timestep in seconds
  65072. */
  65073. getTimeStep(): number;
  65074. /**
  65075. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65076. */
  65077. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65078. private _isImpostorInContact;
  65079. private _isImpostorPairInContact;
  65080. private _stepSimulation;
  65081. /**
  65082. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65083. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65084. * After the step the babylon meshes are set to the position of the physics imposters
  65085. * @param delta amount of time to step forward
  65086. * @param impostors array of imposters to update before/after the step
  65087. */
  65088. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65089. /**
  65090. * Update babylon mesh to match physics world object
  65091. * @param impostor imposter to match
  65092. */
  65093. private _afterSoftStep;
  65094. /**
  65095. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65096. * @param impostor imposter to match
  65097. */
  65098. private _ropeStep;
  65099. /**
  65100. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65101. * @param impostor imposter to match
  65102. */
  65103. private _softbodyOrClothStep;
  65104. private _tmpMatrix;
  65105. /**
  65106. * Applies an impulse on the imposter
  65107. * @param impostor imposter to apply impulse to
  65108. * @param force amount of force to be applied to the imposter
  65109. * @param contactPoint the location to apply the impulse on the imposter
  65110. */
  65111. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65112. /**
  65113. * Applies a force on the imposter
  65114. * @param impostor imposter to apply force
  65115. * @param force amount of force to be applied to the imposter
  65116. * @param contactPoint the location to apply the force on the imposter
  65117. */
  65118. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65119. /**
  65120. * Creates a physics body using the plugin
  65121. * @param impostor the imposter to create the physics body on
  65122. */
  65123. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65124. /**
  65125. * Removes the physics body from the imposter and disposes of the body's memory
  65126. * @param impostor imposter to remove the physics body from
  65127. */
  65128. removePhysicsBody(impostor: PhysicsImpostor): void;
  65129. /**
  65130. * Generates a joint
  65131. * @param impostorJoint the imposter joint to create the joint with
  65132. */
  65133. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65134. /**
  65135. * Removes a joint
  65136. * @param impostorJoint the imposter joint to remove the joint from
  65137. */
  65138. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65139. private _addMeshVerts;
  65140. /**
  65141. * Initialise the soft body vertices to match its object's (mesh) vertices
  65142. * Softbody vertices (nodes) are in world space and to match this
  65143. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65144. * @param impostor to create the softbody for
  65145. */
  65146. private _softVertexData;
  65147. /**
  65148. * Create an impostor's soft body
  65149. * @param impostor to create the softbody for
  65150. */
  65151. private _createSoftbody;
  65152. /**
  65153. * Create cloth for an impostor
  65154. * @param impostor to create the softbody for
  65155. */
  65156. private _createCloth;
  65157. /**
  65158. * Create rope for an impostor
  65159. * @param impostor to create the softbody for
  65160. */
  65161. private _createRope;
  65162. /**
  65163. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65164. * @param impostor to create the custom physics shape for
  65165. */
  65166. private _createCustom;
  65167. private _addHullVerts;
  65168. private _createShape;
  65169. /**
  65170. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65171. * @param impostor imposter containing the physics body and babylon object
  65172. */
  65173. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65174. /**
  65175. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65176. * @param impostor imposter containing the physics body and babylon object
  65177. * @param newPosition new position
  65178. * @param newRotation new rotation
  65179. */
  65180. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65181. /**
  65182. * If this plugin is supported
  65183. * @returns true if its supported
  65184. */
  65185. isSupported(): boolean;
  65186. /**
  65187. * Sets the linear velocity of the physics body
  65188. * @param impostor imposter to set the velocity on
  65189. * @param velocity velocity to set
  65190. */
  65191. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65192. /**
  65193. * Sets the angular velocity of the physics body
  65194. * @param impostor imposter to set the velocity on
  65195. * @param velocity velocity to set
  65196. */
  65197. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65198. /**
  65199. * gets the linear velocity
  65200. * @param impostor imposter to get linear velocity from
  65201. * @returns linear velocity
  65202. */
  65203. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65204. /**
  65205. * gets the angular velocity
  65206. * @param impostor imposter to get angular velocity from
  65207. * @returns angular velocity
  65208. */
  65209. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65210. /**
  65211. * Sets the mass of physics body
  65212. * @param impostor imposter to set the mass on
  65213. * @param mass mass to set
  65214. */
  65215. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65216. /**
  65217. * Gets the mass of the physics body
  65218. * @param impostor imposter to get the mass from
  65219. * @returns mass
  65220. */
  65221. getBodyMass(impostor: PhysicsImpostor): number;
  65222. /**
  65223. * Gets friction of the impostor
  65224. * @param impostor impostor to get friction from
  65225. * @returns friction value
  65226. */
  65227. getBodyFriction(impostor: PhysicsImpostor): number;
  65228. /**
  65229. * Sets friction of the impostor
  65230. * @param impostor impostor to set friction on
  65231. * @param friction friction value
  65232. */
  65233. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65234. /**
  65235. * Gets restitution of the impostor
  65236. * @param impostor impostor to get restitution from
  65237. * @returns restitution value
  65238. */
  65239. getBodyRestitution(impostor: PhysicsImpostor): number;
  65240. /**
  65241. * Sets resitution of the impostor
  65242. * @param impostor impostor to set resitution on
  65243. * @param restitution resitution value
  65244. */
  65245. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65246. /**
  65247. * Gets pressure inside the impostor
  65248. * @param impostor impostor to get pressure from
  65249. * @returns pressure value
  65250. */
  65251. getBodyPressure(impostor: PhysicsImpostor): number;
  65252. /**
  65253. * Sets pressure inside a soft body impostor
  65254. * Cloth and rope must remain 0 pressure
  65255. * @param impostor impostor to set pressure on
  65256. * @param pressure pressure value
  65257. */
  65258. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65259. /**
  65260. * Gets stiffness of the impostor
  65261. * @param impostor impostor to get stiffness from
  65262. * @returns pressure value
  65263. */
  65264. getBodyStiffness(impostor: PhysicsImpostor): number;
  65265. /**
  65266. * Sets stiffness of the impostor
  65267. * @param impostor impostor to set stiffness on
  65268. * @param stiffness stiffness value from 0 to 1
  65269. */
  65270. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65271. /**
  65272. * Gets velocityIterations of the impostor
  65273. * @param impostor impostor to get velocity iterations from
  65274. * @returns velocityIterations value
  65275. */
  65276. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65277. /**
  65278. * Sets velocityIterations of the impostor
  65279. * @param impostor impostor to set velocity iterations on
  65280. * @param velocityIterations velocityIterations value
  65281. */
  65282. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65283. /**
  65284. * Gets positionIterations of the impostor
  65285. * @param impostor impostor to get position iterations from
  65286. * @returns positionIterations value
  65287. */
  65288. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65289. /**
  65290. * Sets positionIterations of the impostor
  65291. * @param impostor impostor to set position on
  65292. * @param positionIterations positionIterations value
  65293. */
  65294. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65295. /**
  65296. * Append an anchor to a cloth object
  65297. * @param impostor is the cloth impostor to add anchor to
  65298. * @param otherImpostor is the rigid impostor to anchor to
  65299. * @param width ratio across width from 0 to 1
  65300. * @param height ratio up height from 0 to 1
  65301. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65302. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65303. */
  65304. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65305. /**
  65306. * Append an hook to a rope object
  65307. * @param impostor is the rope impostor to add hook to
  65308. * @param otherImpostor is the rigid impostor to hook to
  65309. * @param length ratio along the rope from 0 to 1
  65310. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65311. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65312. */
  65313. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65314. /**
  65315. * Sleeps the physics body and stops it from being active
  65316. * @param impostor impostor to sleep
  65317. */
  65318. sleepBody(impostor: PhysicsImpostor): void;
  65319. /**
  65320. * Activates the physics body
  65321. * @param impostor impostor to activate
  65322. */
  65323. wakeUpBody(impostor: PhysicsImpostor): void;
  65324. /**
  65325. * Updates the distance parameters of the joint
  65326. * @param joint joint to update
  65327. * @param maxDistance maximum distance of the joint
  65328. * @param minDistance minimum distance of the joint
  65329. */
  65330. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65331. /**
  65332. * Sets a motor on the joint
  65333. * @param joint joint to set motor on
  65334. * @param speed speed of the motor
  65335. * @param maxForce maximum force of the motor
  65336. * @param motorIndex index of the motor
  65337. */
  65338. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65339. /**
  65340. * Sets the motors limit
  65341. * @param joint joint to set limit on
  65342. * @param upperLimit upper limit
  65343. * @param lowerLimit lower limit
  65344. */
  65345. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65346. /**
  65347. * Syncs the position and rotation of a mesh with the impostor
  65348. * @param mesh mesh to sync
  65349. * @param impostor impostor to update the mesh with
  65350. */
  65351. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65352. /**
  65353. * Gets the radius of the impostor
  65354. * @param impostor impostor to get radius from
  65355. * @returns the radius
  65356. */
  65357. getRadius(impostor: PhysicsImpostor): number;
  65358. /**
  65359. * Gets the box size of the impostor
  65360. * @param impostor impostor to get box size from
  65361. * @param result the resulting box size
  65362. */
  65363. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65364. /**
  65365. * Disposes of the impostor
  65366. */
  65367. dispose(): void;
  65368. /**
  65369. * Does a raycast in the physics world
  65370. * @param from when should the ray start?
  65371. * @param to when should the ray end?
  65372. * @returns PhysicsRaycastResult
  65373. */
  65374. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65375. }
  65376. }
  65377. declare module BABYLON {
  65378. interface AbstractScene {
  65379. /**
  65380. * The list of reflection probes added to the scene
  65381. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65382. */
  65383. reflectionProbes: Array<ReflectionProbe>;
  65384. /**
  65385. * Removes the given reflection probe from this scene.
  65386. * @param toRemove The reflection probe to remove
  65387. * @returns The index of the removed reflection probe
  65388. */
  65389. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65390. /**
  65391. * Adds the given reflection probe to this scene.
  65392. * @param newReflectionProbe The reflection probe to add
  65393. */
  65394. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65395. }
  65396. /**
  65397. * Class used to generate realtime reflection / refraction cube textures
  65398. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65399. */
  65400. export class ReflectionProbe {
  65401. /** defines the name of the probe */
  65402. name: string;
  65403. private _scene;
  65404. private _renderTargetTexture;
  65405. private _projectionMatrix;
  65406. private _viewMatrix;
  65407. private _target;
  65408. private _add;
  65409. private _attachedMesh;
  65410. private _invertYAxis;
  65411. /** Gets or sets probe position (center of the cube map) */
  65412. position: Vector3;
  65413. /**
  65414. * Creates a new reflection probe
  65415. * @param name defines the name of the probe
  65416. * @param size defines the texture resolution (for each face)
  65417. * @param scene defines the hosting scene
  65418. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65419. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65420. */
  65421. constructor(
  65422. /** defines the name of the probe */
  65423. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65424. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65425. get samples(): number;
  65426. set samples(value: number);
  65427. /** Gets or sets the refresh rate to use (on every frame by default) */
  65428. get refreshRate(): number;
  65429. set refreshRate(value: number);
  65430. /**
  65431. * Gets the hosting scene
  65432. * @returns a Scene
  65433. */
  65434. getScene(): Scene;
  65435. /** Gets the internal CubeTexture used to render to */
  65436. get cubeTexture(): RenderTargetTexture;
  65437. /** Gets the list of meshes to render */
  65438. get renderList(): Nullable<AbstractMesh[]>;
  65439. /**
  65440. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65441. * @param mesh defines the mesh to attach to
  65442. */
  65443. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65444. /**
  65445. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65446. * @param renderingGroupId The rendering group id corresponding to its index
  65447. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65448. */
  65449. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65450. /**
  65451. * Clean all associated resources
  65452. */
  65453. dispose(): void;
  65454. /**
  65455. * Converts the reflection probe information to a readable string for debug purpose.
  65456. * @param fullDetails Supports for multiple levels of logging within scene loading
  65457. * @returns the human readable reflection probe info
  65458. */
  65459. toString(fullDetails?: boolean): string;
  65460. /**
  65461. * Get the class name of the relfection probe.
  65462. * @returns "ReflectionProbe"
  65463. */
  65464. getClassName(): string;
  65465. /**
  65466. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65467. * @returns The JSON representation of the texture
  65468. */
  65469. serialize(): any;
  65470. /**
  65471. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65472. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65473. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65474. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65475. * @returns The parsed reflection probe if successful
  65476. */
  65477. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65478. }
  65479. }
  65480. declare module BABYLON {
  65481. /** @hidden */
  65482. export var _BabylonLoaderRegistered: boolean;
  65483. /**
  65484. * Helps setting up some configuration for the babylon file loader.
  65485. */
  65486. export class BabylonFileLoaderConfiguration {
  65487. /**
  65488. * The loader does not allow injecting custom physix engine into the plugins.
  65489. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65490. * So you could set this variable to your engine import to make it work.
  65491. */
  65492. static LoaderInjectedPhysicsEngine: any;
  65493. }
  65494. }
  65495. declare module BABYLON {
  65496. /**
  65497. * A material to use for fast depth-only rendering.
  65498. */
  65499. export class OcclusionMaterial extends ShaderMaterial {
  65500. constructor(name: string, scene: Scene);
  65501. }
  65502. }
  65503. declare module BABYLON {
  65504. /**
  65505. * The Physically based simple base material of BJS.
  65506. *
  65507. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65508. * It is used as the base class for both the specGloss and metalRough conventions.
  65509. */
  65510. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65511. /**
  65512. * Number of Simultaneous lights allowed on the material.
  65513. */
  65514. maxSimultaneousLights: number;
  65515. /**
  65516. * If sets to true, disables all the lights affecting the material.
  65517. */
  65518. disableLighting: boolean;
  65519. /**
  65520. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65521. */
  65522. environmentTexture: BaseTexture;
  65523. /**
  65524. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65525. */
  65526. invertNormalMapX: boolean;
  65527. /**
  65528. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65529. */
  65530. invertNormalMapY: boolean;
  65531. /**
  65532. * Normal map used in the model.
  65533. */
  65534. normalTexture: BaseTexture;
  65535. /**
  65536. * Emissivie color used to self-illuminate the model.
  65537. */
  65538. emissiveColor: Color3;
  65539. /**
  65540. * Emissivie texture used to self-illuminate the model.
  65541. */
  65542. emissiveTexture: BaseTexture;
  65543. /**
  65544. * Occlusion Channel Strenght.
  65545. */
  65546. occlusionStrength: number;
  65547. /**
  65548. * Occlusion Texture of the material (adding extra occlusion effects).
  65549. */
  65550. occlusionTexture: BaseTexture;
  65551. /**
  65552. * Defines the alpha limits in alpha test mode.
  65553. */
  65554. alphaCutOff: number;
  65555. /**
  65556. * Gets the current double sided mode.
  65557. */
  65558. get doubleSided(): boolean;
  65559. /**
  65560. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65561. */
  65562. set doubleSided(value: boolean);
  65563. /**
  65564. * Stores the pre-calculated light information of a mesh in a texture.
  65565. */
  65566. lightmapTexture: BaseTexture;
  65567. /**
  65568. * If true, the light map contains occlusion information instead of lighting info.
  65569. */
  65570. useLightmapAsShadowmap: boolean;
  65571. /**
  65572. * Instantiates a new PBRMaterial instance.
  65573. *
  65574. * @param name The material name
  65575. * @param scene The scene the material will be use in.
  65576. */
  65577. constructor(name: string, scene: Scene);
  65578. getClassName(): string;
  65579. }
  65580. }
  65581. declare module BABYLON {
  65582. /**
  65583. * The PBR material of BJS following the metal roughness convention.
  65584. *
  65585. * This fits to the PBR convention in the GLTF definition:
  65586. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65587. */
  65588. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65589. /**
  65590. * The base color has two different interpretations depending on the value of metalness.
  65591. * When the material is a metal, the base color is the specific measured reflectance value
  65592. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65593. * of the material.
  65594. */
  65595. baseColor: Color3;
  65596. /**
  65597. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65598. * well as opacity information in the alpha channel.
  65599. */
  65600. baseTexture: BaseTexture;
  65601. /**
  65602. * Specifies the metallic scalar value of the material.
  65603. * Can also be used to scale the metalness values of the metallic texture.
  65604. */
  65605. metallic: number;
  65606. /**
  65607. * Specifies the roughness scalar value of the material.
  65608. * Can also be used to scale the roughness values of the metallic texture.
  65609. */
  65610. roughness: number;
  65611. /**
  65612. * Texture containing both the metallic value in the B channel and the
  65613. * roughness value in the G channel to keep better precision.
  65614. */
  65615. metallicRoughnessTexture: BaseTexture;
  65616. /**
  65617. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65618. *
  65619. * @param name The material name
  65620. * @param scene The scene the material will be use in.
  65621. */
  65622. constructor(name: string, scene: Scene);
  65623. /**
  65624. * Return the currrent class name of the material.
  65625. */
  65626. getClassName(): string;
  65627. /**
  65628. * Makes a duplicate of the current material.
  65629. * @param name - name to use for the new material.
  65630. */
  65631. clone(name: string): PBRMetallicRoughnessMaterial;
  65632. /**
  65633. * Serialize the material to a parsable JSON object.
  65634. */
  65635. serialize(): any;
  65636. /**
  65637. * Parses a JSON object correponding to the serialize function.
  65638. */
  65639. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65640. }
  65641. }
  65642. declare module BABYLON {
  65643. /**
  65644. * The PBR material of BJS following the specular glossiness convention.
  65645. *
  65646. * This fits to the PBR convention in the GLTF definition:
  65647. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65648. */
  65649. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65650. /**
  65651. * Specifies the diffuse color of the material.
  65652. */
  65653. diffuseColor: Color3;
  65654. /**
  65655. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65656. * channel.
  65657. */
  65658. diffuseTexture: BaseTexture;
  65659. /**
  65660. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65661. */
  65662. specularColor: Color3;
  65663. /**
  65664. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65665. */
  65666. glossiness: number;
  65667. /**
  65668. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65669. */
  65670. specularGlossinessTexture: BaseTexture;
  65671. /**
  65672. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  65673. */
  65674. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  65675. /**
  65676. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65677. *
  65678. * @param name The material name
  65679. * @param scene The scene the material will be use in.
  65680. */
  65681. constructor(name: string, scene: Scene);
  65682. /**
  65683. * Return the currrent class name of the material.
  65684. */
  65685. getClassName(): string;
  65686. /**
  65687. * Makes a duplicate of the current material.
  65688. * @param name - name to use for the new material.
  65689. */
  65690. clone(name: string): PBRSpecularGlossinessMaterial;
  65691. /**
  65692. * Serialize the material to a parsable JSON object.
  65693. */
  65694. serialize(): any;
  65695. /**
  65696. * Parses a JSON object correponding to the serialize function.
  65697. */
  65698. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65699. }
  65700. }
  65701. declare module BABYLON {
  65702. /**
  65703. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65704. * It can help converting any input color in a desired output one. This can then be used to create effects
  65705. * from sepia, black and white to sixties or futuristic rendering...
  65706. *
  65707. * The only supported format is currently 3dl.
  65708. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65709. */
  65710. export class ColorGradingTexture extends BaseTexture {
  65711. /**
  65712. * The texture URL.
  65713. */
  65714. url: string;
  65715. /**
  65716. * Empty line regex stored for GC.
  65717. */
  65718. private static _noneEmptyLineRegex;
  65719. private _textureMatrix;
  65720. private _onLoad;
  65721. /**
  65722. * Instantiates a ColorGradingTexture from the following parameters.
  65723. *
  65724. * @param url The location of the color gradind data (currently only supporting 3dl)
  65725. * @param sceneOrEngine The scene or engine the texture will be used in
  65726. * @param onLoad defines a callback triggered when the texture has been loaded
  65727. */
  65728. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65729. /**
  65730. * Fires the onload event from the constructor if requested.
  65731. */
  65732. private _triggerOnLoad;
  65733. /**
  65734. * Returns the texture matrix used in most of the material.
  65735. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65736. */
  65737. getTextureMatrix(): Matrix;
  65738. /**
  65739. * Occurs when the file being loaded is a .3dl LUT file.
  65740. */
  65741. private load3dlTexture;
  65742. /**
  65743. * Starts the loading process of the texture.
  65744. */
  65745. private loadTexture;
  65746. /**
  65747. * Clones the color gradind texture.
  65748. */
  65749. clone(): ColorGradingTexture;
  65750. /**
  65751. * Called during delayed load for textures.
  65752. */
  65753. delayLoad(): void;
  65754. /**
  65755. * Parses a color grading texture serialized by Babylon.
  65756. * @param parsedTexture The texture information being parsedTexture
  65757. * @param scene The scene to load the texture in
  65758. * @param rootUrl The root url of the data assets to load
  65759. * @return A color gradind texture
  65760. */
  65761. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65762. /**
  65763. * Serializes the LUT texture to json format.
  65764. */
  65765. serialize(): any;
  65766. }
  65767. }
  65768. declare module BABYLON {
  65769. /**
  65770. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65771. */
  65772. export class EquiRectangularCubeTexture extends BaseTexture {
  65773. /** The six faces of the cube. */
  65774. private static _FacesMapping;
  65775. private _noMipmap;
  65776. private _onLoad;
  65777. private _onError;
  65778. /** The size of the cubemap. */
  65779. private _size;
  65780. /** The buffer of the image. */
  65781. private _buffer;
  65782. /** The width of the input image. */
  65783. private _width;
  65784. /** The height of the input image. */
  65785. private _height;
  65786. /** The URL to the image. */
  65787. url: string;
  65788. /**
  65789. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65790. * @param url The location of the image
  65791. * @param scene The scene the texture will be used in
  65792. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65793. * @param noMipmap Forces to not generate the mipmap if true
  65794. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65795. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65796. * @param onLoad — defines a callback called when texture is loaded
  65797. * @param onError — defines a callback called if there is an error
  65798. */
  65799. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65800. /**
  65801. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65802. */
  65803. private loadImage;
  65804. /**
  65805. * Convert the image buffer into a cubemap and create a CubeTexture.
  65806. */
  65807. private loadTexture;
  65808. /**
  65809. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65810. * @param buffer The ArrayBuffer that should be converted.
  65811. * @returns The buffer as Float32Array.
  65812. */
  65813. private getFloat32ArrayFromArrayBuffer;
  65814. /**
  65815. * Get the current class name of the texture useful for serialization or dynamic coding.
  65816. * @returns "EquiRectangularCubeTexture"
  65817. */
  65818. getClassName(): string;
  65819. /**
  65820. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65821. * @returns A clone of the current EquiRectangularCubeTexture.
  65822. */
  65823. clone(): EquiRectangularCubeTexture;
  65824. }
  65825. }
  65826. declare module BABYLON {
  65827. /**
  65828. * Defines the options related to the creation of an HtmlElementTexture
  65829. */
  65830. export interface IHtmlElementTextureOptions {
  65831. /**
  65832. * Defines wether mip maps should be created or not.
  65833. */
  65834. generateMipMaps?: boolean;
  65835. /**
  65836. * Defines the sampling mode of the texture.
  65837. */
  65838. samplingMode?: number;
  65839. /**
  65840. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65841. */
  65842. engine: Nullable<ThinEngine>;
  65843. /**
  65844. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65845. */
  65846. scene: Nullable<Scene>;
  65847. }
  65848. /**
  65849. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65850. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65851. * is automatically managed.
  65852. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65853. * in your application.
  65854. *
  65855. * As the update is not automatic, you need to call them manually.
  65856. */
  65857. export class HtmlElementTexture extends BaseTexture {
  65858. /**
  65859. * The texture URL.
  65860. */
  65861. element: HTMLVideoElement | HTMLCanvasElement;
  65862. private static readonly DefaultOptions;
  65863. private _textureMatrix;
  65864. private _isVideo;
  65865. private _generateMipMaps;
  65866. private _samplingMode;
  65867. /**
  65868. * Instantiates a HtmlElementTexture from the following parameters.
  65869. *
  65870. * @param name Defines the name of the texture
  65871. * @param element Defines the video or canvas the texture is filled with
  65872. * @param options Defines the other none mandatory texture creation options
  65873. */
  65874. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65875. private _createInternalTexture;
  65876. /**
  65877. * Returns the texture matrix used in most of the material.
  65878. */
  65879. getTextureMatrix(): Matrix;
  65880. /**
  65881. * Updates the content of the texture.
  65882. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65883. */
  65884. update(invertY?: Nullable<boolean>): void;
  65885. }
  65886. }
  65887. declare module BABYLON {
  65888. /**
  65889. * Based on jsTGALoader - Javascript loader for TGA file
  65890. * By Vincent Thibault
  65891. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65892. */
  65893. export class TGATools {
  65894. private static _TYPE_INDEXED;
  65895. private static _TYPE_RGB;
  65896. private static _TYPE_GREY;
  65897. private static _TYPE_RLE_INDEXED;
  65898. private static _TYPE_RLE_RGB;
  65899. private static _TYPE_RLE_GREY;
  65900. private static _ORIGIN_MASK;
  65901. private static _ORIGIN_SHIFT;
  65902. private static _ORIGIN_BL;
  65903. private static _ORIGIN_BR;
  65904. private static _ORIGIN_UL;
  65905. private static _ORIGIN_UR;
  65906. /**
  65907. * Gets the header of a TGA file
  65908. * @param data defines the TGA data
  65909. * @returns the header
  65910. */
  65911. static GetTGAHeader(data: Uint8Array): any;
  65912. /**
  65913. * Uploads TGA content to a Babylon Texture
  65914. * @hidden
  65915. */
  65916. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65917. /** @hidden */
  65918. 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;
  65919. /** @hidden */
  65920. 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;
  65921. /** @hidden */
  65922. 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;
  65923. /** @hidden */
  65924. 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;
  65925. /** @hidden */
  65926. 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;
  65927. /** @hidden */
  65928. 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;
  65929. }
  65930. }
  65931. declare module BABYLON {
  65932. /**
  65933. * Implementation of the TGA Texture Loader.
  65934. * @hidden
  65935. */
  65936. export class _TGATextureLoader implements IInternalTextureLoader {
  65937. /**
  65938. * Defines wether the loader supports cascade loading the different faces.
  65939. */
  65940. readonly supportCascades: boolean;
  65941. /**
  65942. * This returns if the loader support the current file information.
  65943. * @param extension defines the file extension of the file being loaded
  65944. * @returns true if the loader can load the specified file
  65945. */
  65946. canLoad(extension: string): boolean;
  65947. /**
  65948. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65949. * @param data contains the texture data
  65950. * @param texture defines the BabylonJS internal texture
  65951. * @param createPolynomials will be true if polynomials have been requested
  65952. * @param onLoad defines the callback to trigger once the texture is ready
  65953. * @param onError defines the callback to trigger in case of error
  65954. */
  65955. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65956. /**
  65957. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65958. * @param data contains the texture data
  65959. * @param texture defines the BabylonJS internal texture
  65960. * @param callback defines the method to call once ready to upload
  65961. */
  65962. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65963. }
  65964. }
  65965. declare module BABYLON {
  65966. /**
  65967. * Info about the .basis files
  65968. */
  65969. class BasisFileInfo {
  65970. /**
  65971. * If the file has alpha
  65972. */
  65973. hasAlpha: boolean;
  65974. /**
  65975. * Info about each image of the basis file
  65976. */
  65977. images: Array<{
  65978. levels: Array<{
  65979. width: number;
  65980. height: number;
  65981. transcodedPixels: ArrayBufferView;
  65982. }>;
  65983. }>;
  65984. }
  65985. /**
  65986. * Result of transcoding a basis file
  65987. */
  65988. class TranscodeResult {
  65989. /**
  65990. * Info about the .basis file
  65991. */
  65992. fileInfo: BasisFileInfo;
  65993. /**
  65994. * Format to use when loading the file
  65995. */
  65996. format: number;
  65997. }
  65998. /**
  65999. * Configuration options for the Basis transcoder
  66000. */
  66001. export class BasisTranscodeConfiguration {
  66002. /**
  66003. * Supported compression formats used to determine the supported output format of the transcoder
  66004. */
  66005. supportedCompressionFormats?: {
  66006. /**
  66007. * etc1 compression format
  66008. */
  66009. etc1?: boolean;
  66010. /**
  66011. * s3tc compression format
  66012. */
  66013. s3tc?: boolean;
  66014. /**
  66015. * pvrtc compression format
  66016. */
  66017. pvrtc?: boolean;
  66018. /**
  66019. * etc2 compression format
  66020. */
  66021. etc2?: boolean;
  66022. };
  66023. /**
  66024. * If mipmap levels should be loaded for transcoded images (Default: true)
  66025. */
  66026. loadMipmapLevels?: boolean;
  66027. /**
  66028. * Index of a single image to load (Default: all images)
  66029. */
  66030. loadSingleImage?: number;
  66031. }
  66032. /**
  66033. * Used to load .Basis files
  66034. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66035. */
  66036. export class BasisTools {
  66037. private static _IgnoreSupportedFormats;
  66038. /**
  66039. * URL to use when loading the basis transcoder
  66040. */
  66041. static JSModuleURL: string;
  66042. /**
  66043. * URL to use when loading the wasm module for the transcoder
  66044. */
  66045. static WasmModuleURL: string;
  66046. /**
  66047. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66048. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66049. * @returns internal format corresponding to the Basis format
  66050. */
  66051. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66052. private static _WorkerPromise;
  66053. private static _Worker;
  66054. private static _actionId;
  66055. private static _CreateWorkerAsync;
  66056. /**
  66057. * Transcodes a loaded image file to compressed pixel data
  66058. * @param data image data to transcode
  66059. * @param config configuration options for the transcoding
  66060. * @returns a promise resulting in the transcoded image
  66061. */
  66062. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66063. /**
  66064. * Loads a texture from the transcode result
  66065. * @param texture texture load to
  66066. * @param transcodeResult the result of transcoding the basis file to load from
  66067. */
  66068. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66069. }
  66070. }
  66071. declare module BABYLON {
  66072. /**
  66073. * Loader for .basis file format
  66074. */
  66075. export class _BasisTextureLoader implements IInternalTextureLoader {
  66076. /**
  66077. * Defines whether the loader supports cascade loading the different faces.
  66078. */
  66079. readonly supportCascades: boolean;
  66080. /**
  66081. * This returns if the loader support the current file information.
  66082. * @param extension defines the file extension of the file being loaded
  66083. * @returns true if the loader can load the specified file
  66084. */
  66085. canLoad(extension: string): boolean;
  66086. /**
  66087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66088. * @param data contains the texture data
  66089. * @param texture defines the BabylonJS internal texture
  66090. * @param createPolynomials will be true if polynomials have been requested
  66091. * @param onLoad defines the callback to trigger once the texture is ready
  66092. * @param onError defines the callback to trigger in case of error
  66093. */
  66094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66095. /**
  66096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66097. * @param data contains the texture data
  66098. * @param texture defines the BabylonJS internal texture
  66099. * @param callback defines the method to call once ready to upload
  66100. */
  66101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66102. }
  66103. }
  66104. declare module BABYLON {
  66105. /**
  66106. * Defines the basic options interface of a TexturePacker Frame
  66107. */
  66108. export interface ITexturePackerFrame {
  66109. /**
  66110. * The frame ID
  66111. */
  66112. id: number;
  66113. /**
  66114. * The frames Scale
  66115. */
  66116. scale: Vector2;
  66117. /**
  66118. * The Frames offset
  66119. */
  66120. offset: Vector2;
  66121. }
  66122. /**
  66123. * This is a support class for frame Data on texture packer sets.
  66124. */
  66125. export class TexturePackerFrame implements ITexturePackerFrame {
  66126. /**
  66127. * The frame ID
  66128. */
  66129. id: number;
  66130. /**
  66131. * The frames Scale
  66132. */
  66133. scale: Vector2;
  66134. /**
  66135. * The Frames offset
  66136. */
  66137. offset: Vector2;
  66138. /**
  66139. * Initializes a texture package frame.
  66140. * @param id The numerical frame identifier
  66141. * @param scale Scalar Vector2 for UV frame
  66142. * @param offset Vector2 for the frame position in UV units.
  66143. * @returns TexturePackerFrame
  66144. */
  66145. constructor(id: number, scale: Vector2, offset: Vector2);
  66146. }
  66147. }
  66148. declare module BABYLON {
  66149. /**
  66150. * Defines the basic options interface of a TexturePacker
  66151. */
  66152. export interface ITexturePackerOptions {
  66153. /**
  66154. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66155. */
  66156. map?: string[];
  66157. /**
  66158. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66159. */
  66160. uvsIn?: string;
  66161. /**
  66162. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66163. */
  66164. uvsOut?: string;
  66165. /**
  66166. * number representing the layout style. Defaults to LAYOUT_STRIP
  66167. */
  66168. layout?: number;
  66169. /**
  66170. * number of columns if using custom column count layout(2). This defaults to 4.
  66171. */
  66172. colnum?: number;
  66173. /**
  66174. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66175. */
  66176. updateInputMeshes?: boolean;
  66177. /**
  66178. * boolean flag to dispose all the source textures. Defaults to true.
  66179. */
  66180. disposeSources?: boolean;
  66181. /**
  66182. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66183. */
  66184. fillBlanks?: boolean;
  66185. /**
  66186. * string value representing the context fill style color. Defaults to 'black'.
  66187. */
  66188. customFillColor?: string;
  66189. /**
  66190. * Width and Height Value of each Frame in the TexturePacker Sets
  66191. */
  66192. frameSize?: number;
  66193. /**
  66194. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66195. */
  66196. paddingRatio?: number;
  66197. /**
  66198. * Number that declares the fill method for the padding gutter.
  66199. */
  66200. paddingMode?: number;
  66201. /**
  66202. * If in SUBUV_COLOR padding mode what color to use.
  66203. */
  66204. paddingColor?: Color3 | Color4;
  66205. }
  66206. /**
  66207. * Defines the basic interface of a TexturePacker JSON File
  66208. */
  66209. export interface ITexturePackerJSON {
  66210. /**
  66211. * The frame ID
  66212. */
  66213. name: string;
  66214. /**
  66215. * The base64 channel data
  66216. */
  66217. sets: any;
  66218. /**
  66219. * The options of the Packer
  66220. */
  66221. options: ITexturePackerOptions;
  66222. /**
  66223. * The frame data of the Packer
  66224. */
  66225. frames: Array<number>;
  66226. }
  66227. /**
  66228. * This is a support class that generates a series of packed texture sets.
  66229. * @see https://doc.babylonjs.com/babylon101/materials
  66230. */
  66231. export class TexturePacker {
  66232. /** Packer Layout Constant 0 */
  66233. static readonly LAYOUT_STRIP: number;
  66234. /** Packer Layout Constant 1 */
  66235. static readonly LAYOUT_POWER2: number;
  66236. /** Packer Layout Constant 2 */
  66237. static readonly LAYOUT_COLNUM: number;
  66238. /** Packer Layout Constant 0 */
  66239. static readonly SUBUV_WRAP: number;
  66240. /** Packer Layout Constant 1 */
  66241. static readonly SUBUV_EXTEND: number;
  66242. /** Packer Layout Constant 2 */
  66243. static readonly SUBUV_COLOR: number;
  66244. /** The Name of the Texture Package */
  66245. name: string;
  66246. /** The scene scope of the TexturePacker */
  66247. scene: Scene;
  66248. /** The Meshes to target */
  66249. meshes: AbstractMesh[];
  66250. /** Arguments passed with the Constructor */
  66251. options: ITexturePackerOptions;
  66252. /** The promise that is started upon initialization */
  66253. promise: Nullable<Promise<TexturePacker | string>>;
  66254. /** The Container object for the channel sets that are generated */
  66255. sets: object;
  66256. /** The Container array for the frames that are generated */
  66257. frames: TexturePackerFrame[];
  66258. /** The expected number of textures the system is parsing. */
  66259. private _expecting;
  66260. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66261. private _paddingValue;
  66262. /**
  66263. * Initializes a texture package series from an array of meshes or a single mesh.
  66264. * @param name The name of the package
  66265. * @param meshes The target meshes to compose the package from
  66266. * @param options The arguments that texture packer should follow while building.
  66267. * @param scene The scene which the textures are scoped to.
  66268. * @returns TexturePacker
  66269. */
  66270. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66271. /**
  66272. * Starts the package process
  66273. * @param resolve The promises resolution function
  66274. * @returns TexturePacker
  66275. */
  66276. private _createFrames;
  66277. /**
  66278. * Calculates the Size of the Channel Sets
  66279. * @returns Vector2
  66280. */
  66281. private _calculateSize;
  66282. /**
  66283. * Calculates the UV data for the frames.
  66284. * @param baseSize the base frameSize
  66285. * @param padding the base frame padding
  66286. * @param dtSize size of the Dynamic Texture for that channel
  66287. * @param dtUnits is 1/dtSize
  66288. * @param update flag to update the input meshes
  66289. */
  66290. private _calculateMeshUVFrames;
  66291. /**
  66292. * Calculates the frames Offset.
  66293. * @param index of the frame
  66294. * @returns Vector2
  66295. */
  66296. private _getFrameOffset;
  66297. /**
  66298. * Updates a Mesh to the frame data
  66299. * @param mesh that is the target
  66300. * @param frameID or the frame index
  66301. */
  66302. private _updateMeshUV;
  66303. /**
  66304. * Updates a Meshes materials to use the texture packer channels
  66305. * @param m is the mesh to target
  66306. * @param force all channels on the packer to be set.
  66307. */
  66308. private _updateTextureReferences;
  66309. /**
  66310. * Public method to set a Mesh to a frame
  66311. * @param m that is the target
  66312. * @param frameID or the frame index
  66313. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66314. */
  66315. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66316. /**
  66317. * Starts the async promise to compile the texture packer.
  66318. * @returns Promise<void>
  66319. */
  66320. processAsync(): Promise<void>;
  66321. /**
  66322. * Disposes all textures associated with this packer
  66323. */
  66324. dispose(): void;
  66325. /**
  66326. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66327. * @param imageType is the image type to use.
  66328. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66329. */
  66330. download(imageType?: string, quality?: number): void;
  66331. /**
  66332. * Public method to load a texturePacker JSON file.
  66333. * @param data of the JSON file in string format.
  66334. */
  66335. updateFromJSON(data: string): void;
  66336. }
  66337. }
  66338. declare module BABYLON {
  66339. /**
  66340. * 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.
  66341. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66342. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66343. */
  66344. export class CustomProceduralTexture extends ProceduralTexture {
  66345. private _animate;
  66346. private _time;
  66347. private _config;
  66348. private _texturePath;
  66349. /**
  66350. * Instantiates a new Custom Procedural Texture.
  66351. * 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.
  66352. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66353. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66354. * @param name Define the name of the texture
  66355. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66356. * @param size Define the size of the texture to create
  66357. * @param scene Define the scene the texture belongs to
  66358. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66359. * @param generateMipMaps Define if the texture should creates mip maps or not
  66360. */
  66361. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66362. private _loadJson;
  66363. /**
  66364. * Is the texture ready to be used ? (rendered at least once)
  66365. * @returns true if ready, otherwise, false.
  66366. */
  66367. isReady(): boolean;
  66368. /**
  66369. * Render the texture to its associated render target.
  66370. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66371. */
  66372. render(useCameraPostProcess?: boolean): void;
  66373. /**
  66374. * Update the list of dependant textures samplers in the shader.
  66375. */
  66376. updateTextures(): void;
  66377. /**
  66378. * Update the uniform values of the procedural texture in the shader.
  66379. */
  66380. updateShaderUniforms(): void;
  66381. /**
  66382. * Define if the texture animates or not.
  66383. */
  66384. get animate(): boolean;
  66385. set animate(value: boolean);
  66386. }
  66387. }
  66388. declare module BABYLON {
  66389. /** @hidden */
  66390. export var noisePixelShader: {
  66391. name: string;
  66392. shader: string;
  66393. };
  66394. }
  66395. declare module BABYLON {
  66396. /**
  66397. * Class used to generate noise procedural textures
  66398. */
  66399. export class NoiseProceduralTexture extends ProceduralTexture {
  66400. /** Gets or sets the start time (default is 0) */
  66401. time: number;
  66402. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66403. brightness: number;
  66404. /** Defines the number of octaves to process */
  66405. octaves: number;
  66406. /** Defines the level of persistence (0.8 by default) */
  66407. persistence: number;
  66408. /** Gets or sets animation speed factor (default is 1) */
  66409. animationSpeedFactor: number;
  66410. /**
  66411. * Creates a new NoiseProceduralTexture
  66412. * @param name defines the name fo the texture
  66413. * @param size defines the size of the texture (default is 256)
  66414. * @param scene defines the hosting scene
  66415. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66416. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66417. */
  66418. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66419. private _updateShaderUniforms;
  66420. protected _getDefines(): string;
  66421. /** Generate the current state of the procedural texture */
  66422. render(useCameraPostProcess?: boolean): void;
  66423. /**
  66424. * Serializes this noise procedural texture
  66425. * @returns a serialized noise procedural texture object
  66426. */
  66427. serialize(): any;
  66428. /**
  66429. * Clone the texture.
  66430. * @returns the cloned texture
  66431. */
  66432. clone(): NoiseProceduralTexture;
  66433. /**
  66434. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66435. * @param parsedTexture defines parsed texture data
  66436. * @param scene defines the current scene
  66437. * @param rootUrl defines the root URL containing noise procedural texture information
  66438. * @returns a parsed NoiseProceduralTexture
  66439. */
  66440. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66441. }
  66442. }
  66443. declare module BABYLON {
  66444. /**
  66445. * Raw cube texture where the raw buffers are passed in
  66446. */
  66447. export class RawCubeTexture extends CubeTexture {
  66448. /**
  66449. * Creates a cube texture where the raw buffers are passed in.
  66450. * @param scene defines the scene the texture is attached to
  66451. * @param data defines the array of data to use to create each face
  66452. * @param size defines the size of the textures
  66453. * @param format defines the format of the data
  66454. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66455. * @param generateMipMaps defines if the engine should generate the mip levels
  66456. * @param invertY defines if data must be stored with Y axis inverted
  66457. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66458. * @param compression defines the compression used (null by default)
  66459. */
  66460. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66461. /**
  66462. * Updates the raw cube texture.
  66463. * @param data defines the data to store
  66464. * @param format defines the data format
  66465. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66466. * @param invertY defines if data must be stored with Y axis inverted
  66467. * @param compression defines the compression used (null by default)
  66468. * @param level defines which level of the texture to update
  66469. */
  66470. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66471. /**
  66472. * Updates a raw cube texture with RGBD encoded data.
  66473. * @param data defines the array of data [mipmap][face] to use to create each face
  66474. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66475. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66476. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66477. * @returns a promsie that resolves when the operation is complete
  66478. */
  66479. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66480. /**
  66481. * Clones the raw cube texture.
  66482. * @return a new cube texture
  66483. */
  66484. clone(): CubeTexture;
  66485. /** @hidden */
  66486. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66487. }
  66488. }
  66489. declare module BABYLON {
  66490. /**
  66491. * Class used to store 2D array textures containing user data
  66492. */
  66493. export class RawTexture2DArray extends Texture {
  66494. /** Gets or sets the texture format to use */
  66495. format: number;
  66496. /**
  66497. * Create a new RawTexture2DArray
  66498. * @param data defines the data of the texture
  66499. * @param width defines the width of the texture
  66500. * @param height defines the height of the texture
  66501. * @param depth defines the number of layers of the texture
  66502. * @param format defines the texture format to use
  66503. * @param scene defines the hosting scene
  66504. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66505. * @param invertY defines if texture must be stored with Y axis inverted
  66506. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66507. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66508. */
  66509. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66510. /** Gets or sets the texture format to use */
  66511. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66512. /**
  66513. * Update the texture with new data
  66514. * @param data defines the data to store in the texture
  66515. */
  66516. update(data: ArrayBufferView): void;
  66517. }
  66518. }
  66519. declare module BABYLON {
  66520. /**
  66521. * Class used to store 3D textures containing user data
  66522. */
  66523. export class RawTexture3D extends Texture {
  66524. /** Gets or sets the texture format to use */
  66525. format: number;
  66526. /**
  66527. * Create a new RawTexture3D
  66528. * @param data defines the data of the texture
  66529. * @param width defines the width of the texture
  66530. * @param height defines the height of the texture
  66531. * @param depth defines the depth of the texture
  66532. * @param format defines the texture format to use
  66533. * @param scene defines the hosting scene
  66534. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66535. * @param invertY defines if texture must be stored with Y axis inverted
  66536. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66537. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66538. */
  66539. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66540. /** Gets or sets the texture format to use */
  66541. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66542. /**
  66543. * Update the texture with new data
  66544. * @param data defines the data to store in the texture
  66545. */
  66546. update(data: ArrayBufferView): void;
  66547. }
  66548. }
  66549. declare module BABYLON {
  66550. /**
  66551. * Creates a refraction texture used by refraction channel of the standard material.
  66552. * It is like a mirror but to see through a material.
  66553. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66554. */
  66555. export class RefractionTexture extends RenderTargetTexture {
  66556. /**
  66557. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66558. * 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.
  66559. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66560. */
  66561. refractionPlane: Plane;
  66562. /**
  66563. * Define how deep under the surface we should see.
  66564. */
  66565. depth: number;
  66566. /**
  66567. * Creates a refraction texture used by refraction channel of the standard material.
  66568. * It is like a mirror but to see through a material.
  66569. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66570. * @param name Define the texture name
  66571. * @param size Define the size of the underlying texture
  66572. * @param scene Define the scene the refraction belongs to
  66573. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66574. */
  66575. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66576. /**
  66577. * Clone the refraction texture.
  66578. * @returns the cloned texture
  66579. */
  66580. clone(): RefractionTexture;
  66581. /**
  66582. * Serialize the texture to a JSON representation you could use in Parse later on
  66583. * @returns the serialized JSON representation
  66584. */
  66585. serialize(): any;
  66586. }
  66587. }
  66588. declare module BABYLON {
  66589. /**
  66590. * Block used to add support for vertex skinning (bones)
  66591. */
  66592. export class BonesBlock extends NodeMaterialBlock {
  66593. /**
  66594. * Creates a new BonesBlock
  66595. * @param name defines the block name
  66596. */
  66597. constructor(name: string);
  66598. /**
  66599. * Initialize the block and prepare the context for build
  66600. * @param state defines the state that will be used for the build
  66601. */
  66602. initialize(state: NodeMaterialBuildState): void;
  66603. /**
  66604. * Gets the current class name
  66605. * @returns the class name
  66606. */
  66607. getClassName(): string;
  66608. /**
  66609. * Gets the matrix indices input component
  66610. */
  66611. get matricesIndices(): NodeMaterialConnectionPoint;
  66612. /**
  66613. * Gets the matrix weights input component
  66614. */
  66615. get matricesWeights(): NodeMaterialConnectionPoint;
  66616. /**
  66617. * Gets the extra matrix indices input component
  66618. */
  66619. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66620. /**
  66621. * Gets the extra matrix weights input component
  66622. */
  66623. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66624. /**
  66625. * Gets the world input component
  66626. */
  66627. get world(): NodeMaterialConnectionPoint;
  66628. /**
  66629. * Gets the output component
  66630. */
  66631. get output(): NodeMaterialConnectionPoint;
  66632. autoConfigure(material: NodeMaterial): void;
  66633. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66634. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66635. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66636. protected _buildBlock(state: NodeMaterialBuildState): this;
  66637. }
  66638. }
  66639. declare module BABYLON {
  66640. /**
  66641. * Block used to add support for instances
  66642. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66643. */
  66644. export class InstancesBlock extends NodeMaterialBlock {
  66645. /**
  66646. * Creates a new InstancesBlock
  66647. * @param name defines the block name
  66648. */
  66649. constructor(name: string);
  66650. /**
  66651. * Gets the current class name
  66652. * @returns the class name
  66653. */
  66654. getClassName(): string;
  66655. /**
  66656. * Gets the first world row input component
  66657. */
  66658. get world0(): NodeMaterialConnectionPoint;
  66659. /**
  66660. * Gets the second world row input component
  66661. */
  66662. get world1(): NodeMaterialConnectionPoint;
  66663. /**
  66664. * Gets the third world row input component
  66665. */
  66666. get world2(): NodeMaterialConnectionPoint;
  66667. /**
  66668. * Gets the forth world row input component
  66669. */
  66670. get world3(): NodeMaterialConnectionPoint;
  66671. /**
  66672. * Gets the world input component
  66673. */
  66674. get world(): NodeMaterialConnectionPoint;
  66675. /**
  66676. * Gets the output component
  66677. */
  66678. get output(): NodeMaterialConnectionPoint;
  66679. /**
  66680. * Gets the isntanceID component
  66681. */
  66682. get instanceID(): NodeMaterialConnectionPoint;
  66683. autoConfigure(material: NodeMaterial): void;
  66684. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66685. protected _buildBlock(state: NodeMaterialBuildState): this;
  66686. }
  66687. }
  66688. declare module BABYLON {
  66689. /**
  66690. * Block used to add morph targets support to vertex shader
  66691. */
  66692. export class MorphTargetsBlock extends NodeMaterialBlock {
  66693. private _repeatableContentAnchor;
  66694. /**
  66695. * Create a new MorphTargetsBlock
  66696. * @param name defines the block name
  66697. */
  66698. constructor(name: string);
  66699. /**
  66700. * Gets the current class name
  66701. * @returns the class name
  66702. */
  66703. getClassName(): string;
  66704. /**
  66705. * Gets the position input component
  66706. */
  66707. get position(): NodeMaterialConnectionPoint;
  66708. /**
  66709. * Gets the normal input component
  66710. */
  66711. get normal(): NodeMaterialConnectionPoint;
  66712. /**
  66713. * Gets the tangent input component
  66714. */
  66715. get tangent(): NodeMaterialConnectionPoint;
  66716. /**
  66717. * Gets the tangent input component
  66718. */
  66719. get uv(): NodeMaterialConnectionPoint;
  66720. /**
  66721. * Gets the position output component
  66722. */
  66723. get positionOutput(): NodeMaterialConnectionPoint;
  66724. /**
  66725. * Gets the normal output component
  66726. */
  66727. get normalOutput(): NodeMaterialConnectionPoint;
  66728. /**
  66729. * Gets the tangent output component
  66730. */
  66731. get tangentOutput(): NodeMaterialConnectionPoint;
  66732. /**
  66733. * Gets the tangent output component
  66734. */
  66735. get uvOutput(): NodeMaterialConnectionPoint;
  66736. initialize(state: NodeMaterialBuildState): void;
  66737. autoConfigure(material: NodeMaterial): void;
  66738. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66739. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66740. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66741. protected _buildBlock(state: NodeMaterialBuildState): this;
  66742. }
  66743. }
  66744. declare module BABYLON {
  66745. /**
  66746. * Block used to get data information from a light
  66747. */
  66748. export class LightInformationBlock extends NodeMaterialBlock {
  66749. private _lightDataUniformName;
  66750. private _lightColorUniformName;
  66751. private _lightTypeDefineName;
  66752. /**
  66753. * Gets or sets the light associated with this block
  66754. */
  66755. light: Nullable<Light>;
  66756. /**
  66757. * Creates a new LightInformationBlock
  66758. * @param name defines the block name
  66759. */
  66760. constructor(name: string);
  66761. /**
  66762. * Gets the current class name
  66763. * @returns the class name
  66764. */
  66765. getClassName(): string;
  66766. /**
  66767. * Gets the world position input component
  66768. */
  66769. get worldPosition(): NodeMaterialConnectionPoint;
  66770. /**
  66771. * Gets the direction output component
  66772. */
  66773. get direction(): NodeMaterialConnectionPoint;
  66774. /**
  66775. * Gets the direction output component
  66776. */
  66777. get color(): NodeMaterialConnectionPoint;
  66778. /**
  66779. * Gets the direction output component
  66780. */
  66781. get intensity(): NodeMaterialConnectionPoint;
  66782. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66784. protected _buildBlock(state: NodeMaterialBuildState): this;
  66785. serialize(): any;
  66786. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66787. }
  66788. }
  66789. declare module BABYLON {
  66790. /**
  66791. * Block used to add image processing support to fragment shader
  66792. */
  66793. export class ImageProcessingBlock extends NodeMaterialBlock {
  66794. /**
  66795. * Create a new ImageProcessingBlock
  66796. * @param name defines the block name
  66797. */
  66798. constructor(name: string);
  66799. /**
  66800. * Gets the current class name
  66801. * @returns the class name
  66802. */
  66803. getClassName(): string;
  66804. /**
  66805. * Gets the color input component
  66806. */
  66807. get color(): NodeMaterialConnectionPoint;
  66808. /**
  66809. * Gets the output component
  66810. */
  66811. get output(): NodeMaterialConnectionPoint;
  66812. /**
  66813. * Initialize the block and prepare the context for build
  66814. * @param state defines the state that will be used for the build
  66815. */
  66816. initialize(state: NodeMaterialBuildState): void;
  66817. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66819. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66820. protected _buildBlock(state: NodeMaterialBuildState): this;
  66821. }
  66822. }
  66823. declare module BABYLON {
  66824. /**
  66825. * Block used to pertub normals based on a normal map
  66826. */
  66827. export class PerturbNormalBlock extends NodeMaterialBlock {
  66828. private _tangentSpaceParameterName;
  66829. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66830. invertX: boolean;
  66831. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66832. invertY: boolean;
  66833. /**
  66834. * Create a new PerturbNormalBlock
  66835. * @param name defines the block name
  66836. */
  66837. constructor(name: string);
  66838. /**
  66839. * Gets the current class name
  66840. * @returns the class name
  66841. */
  66842. getClassName(): string;
  66843. /**
  66844. * Gets the world position input component
  66845. */
  66846. get worldPosition(): NodeMaterialConnectionPoint;
  66847. /**
  66848. * Gets the world normal input component
  66849. */
  66850. get worldNormal(): NodeMaterialConnectionPoint;
  66851. /**
  66852. * Gets the world tangent input component
  66853. */
  66854. get worldTangent(): NodeMaterialConnectionPoint;
  66855. /**
  66856. * Gets the uv input component
  66857. */
  66858. get uv(): NodeMaterialConnectionPoint;
  66859. /**
  66860. * Gets the normal map color input component
  66861. */
  66862. get normalMapColor(): NodeMaterialConnectionPoint;
  66863. /**
  66864. * Gets the strength input component
  66865. */
  66866. get strength(): NodeMaterialConnectionPoint;
  66867. /**
  66868. * Gets the output component
  66869. */
  66870. get output(): NodeMaterialConnectionPoint;
  66871. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66872. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66873. autoConfigure(material: NodeMaterial): void;
  66874. protected _buildBlock(state: NodeMaterialBuildState): this;
  66875. protected _dumpPropertiesCode(): string;
  66876. serialize(): any;
  66877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66878. }
  66879. }
  66880. declare module BABYLON {
  66881. /**
  66882. * Block used to discard a pixel if a value is smaller than a cutoff
  66883. */
  66884. export class DiscardBlock extends NodeMaterialBlock {
  66885. /**
  66886. * Create a new DiscardBlock
  66887. * @param name defines the block name
  66888. */
  66889. constructor(name: string);
  66890. /**
  66891. * Gets the current class name
  66892. * @returns the class name
  66893. */
  66894. getClassName(): string;
  66895. /**
  66896. * Gets the color input component
  66897. */
  66898. get value(): NodeMaterialConnectionPoint;
  66899. /**
  66900. * Gets the cutoff input component
  66901. */
  66902. get cutoff(): NodeMaterialConnectionPoint;
  66903. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66904. }
  66905. }
  66906. declare module BABYLON {
  66907. /**
  66908. * Block used to test if the fragment shader is front facing
  66909. */
  66910. export class FrontFacingBlock extends NodeMaterialBlock {
  66911. /**
  66912. * Creates a new FrontFacingBlock
  66913. * @param name defines the block name
  66914. */
  66915. constructor(name: string);
  66916. /**
  66917. * Gets the current class name
  66918. * @returns the class name
  66919. */
  66920. getClassName(): string;
  66921. /**
  66922. * Gets the output component
  66923. */
  66924. get output(): NodeMaterialConnectionPoint;
  66925. protected _buildBlock(state: NodeMaterialBuildState): this;
  66926. }
  66927. }
  66928. declare module BABYLON {
  66929. /**
  66930. * Block used to get the derivative value on x and y of a given input
  66931. */
  66932. export class DerivativeBlock extends NodeMaterialBlock {
  66933. /**
  66934. * Create a new DerivativeBlock
  66935. * @param name defines the block name
  66936. */
  66937. constructor(name: string);
  66938. /**
  66939. * Gets the current class name
  66940. * @returns the class name
  66941. */
  66942. getClassName(): string;
  66943. /**
  66944. * Gets the input component
  66945. */
  66946. get input(): NodeMaterialConnectionPoint;
  66947. /**
  66948. * Gets the derivative output on x
  66949. */
  66950. get dx(): NodeMaterialConnectionPoint;
  66951. /**
  66952. * Gets the derivative output on y
  66953. */
  66954. get dy(): NodeMaterialConnectionPoint;
  66955. protected _buildBlock(state: NodeMaterialBuildState): this;
  66956. }
  66957. }
  66958. declare module BABYLON {
  66959. /**
  66960. * Block used to make gl_FragCoord available
  66961. */
  66962. export class FragCoordBlock extends NodeMaterialBlock {
  66963. /**
  66964. * Creates a new FragCoordBlock
  66965. * @param name defines the block name
  66966. */
  66967. constructor(name: string);
  66968. /**
  66969. * Gets the current class name
  66970. * @returns the class name
  66971. */
  66972. getClassName(): string;
  66973. /**
  66974. * Gets the xy component
  66975. */
  66976. get xy(): NodeMaterialConnectionPoint;
  66977. /**
  66978. * Gets the xyz component
  66979. */
  66980. get xyz(): NodeMaterialConnectionPoint;
  66981. /**
  66982. * Gets the xyzw component
  66983. */
  66984. get xyzw(): NodeMaterialConnectionPoint;
  66985. /**
  66986. * Gets the x component
  66987. */
  66988. get x(): NodeMaterialConnectionPoint;
  66989. /**
  66990. * Gets the y component
  66991. */
  66992. get y(): NodeMaterialConnectionPoint;
  66993. /**
  66994. * Gets the z component
  66995. */
  66996. get z(): NodeMaterialConnectionPoint;
  66997. /**
  66998. * Gets the w component
  66999. */
  67000. get output(): NodeMaterialConnectionPoint;
  67001. protected writeOutputs(state: NodeMaterialBuildState): string;
  67002. protected _buildBlock(state: NodeMaterialBuildState): this;
  67003. }
  67004. }
  67005. declare module BABYLON {
  67006. /**
  67007. * Block used to get the screen sizes
  67008. */
  67009. export class ScreenSizeBlock extends NodeMaterialBlock {
  67010. private _varName;
  67011. private _scene;
  67012. /**
  67013. * Creates a new ScreenSizeBlock
  67014. * @param name defines the block name
  67015. */
  67016. constructor(name: string);
  67017. /**
  67018. * Gets the current class name
  67019. * @returns the class name
  67020. */
  67021. getClassName(): string;
  67022. /**
  67023. * Gets the xy component
  67024. */
  67025. get xy(): NodeMaterialConnectionPoint;
  67026. /**
  67027. * Gets the x component
  67028. */
  67029. get x(): NodeMaterialConnectionPoint;
  67030. /**
  67031. * Gets the y component
  67032. */
  67033. get y(): NodeMaterialConnectionPoint;
  67034. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67035. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67036. protected _buildBlock(state: NodeMaterialBuildState): this;
  67037. }
  67038. }
  67039. declare module BABYLON {
  67040. /**
  67041. * Block used to add support for scene fog
  67042. */
  67043. export class FogBlock extends NodeMaterialBlock {
  67044. private _fogDistanceName;
  67045. private _fogParameters;
  67046. /**
  67047. * Create a new FogBlock
  67048. * @param name defines the block name
  67049. */
  67050. constructor(name: string);
  67051. /**
  67052. * Gets the current class name
  67053. * @returns the class name
  67054. */
  67055. getClassName(): string;
  67056. /**
  67057. * Gets the world position input component
  67058. */
  67059. get worldPosition(): NodeMaterialConnectionPoint;
  67060. /**
  67061. * Gets the view input component
  67062. */
  67063. get view(): NodeMaterialConnectionPoint;
  67064. /**
  67065. * Gets the color input component
  67066. */
  67067. get input(): NodeMaterialConnectionPoint;
  67068. /**
  67069. * Gets the fog color input component
  67070. */
  67071. get fogColor(): NodeMaterialConnectionPoint;
  67072. /**
  67073. * Gets the output component
  67074. */
  67075. get output(): NodeMaterialConnectionPoint;
  67076. autoConfigure(material: NodeMaterial): void;
  67077. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67078. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67079. protected _buildBlock(state: NodeMaterialBuildState): this;
  67080. }
  67081. }
  67082. declare module BABYLON {
  67083. /**
  67084. * Block used to add light in the fragment shader
  67085. */
  67086. export class LightBlock extends NodeMaterialBlock {
  67087. private _lightId;
  67088. /**
  67089. * Gets or sets the light associated with this block
  67090. */
  67091. light: Nullable<Light>;
  67092. /**
  67093. * Create a new LightBlock
  67094. * @param name defines the block name
  67095. */
  67096. constructor(name: string);
  67097. /**
  67098. * Gets the current class name
  67099. * @returns the class name
  67100. */
  67101. getClassName(): string;
  67102. /**
  67103. * Gets the world position input component
  67104. */
  67105. get worldPosition(): NodeMaterialConnectionPoint;
  67106. /**
  67107. * Gets the world normal input component
  67108. */
  67109. get worldNormal(): NodeMaterialConnectionPoint;
  67110. /**
  67111. * Gets the camera (or eye) position component
  67112. */
  67113. get cameraPosition(): NodeMaterialConnectionPoint;
  67114. /**
  67115. * Gets the glossiness component
  67116. */
  67117. get glossiness(): NodeMaterialConnectionPoint;
  67118. /**
  67119. * Gets the glossinness power component
  67120. */
  67121. get glossPower(): NodeMaterialConnectionPoint;
  67122. /**
  67123. * Gets the diffuse color component
  67124. */
  67125. get diffuseColor(): NodeMaterialConnectionPoint;
  67126. /**
  67127. * Gets the specular color component
  67128. */
  67129. get specularColor(): NodeMaterialConnectionPoint;
  67130. /**
  67131. * Gets the view matrix component
  67132. */
  67133. get view(): NodeMaterialConnectionPoint;
  67134. /**
  67135. * Gets the diffuse output component
  67136. */
  67137. get diffuseOutput(): NodeMaterialConnectionPoint;
  67138. /**
  67139. * Gets the specular output component
  67140. */
  67141. get specularOutput(): NodeMaterialConnectionPoint;
  67142. /**
  67143. * Gets the shadow output component
  67144. */
  67145. get shadow(): NodeMaterialConnectionPoint;
  67146. autoConfigure(material: NodeMaterial): void;
  67147. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67148. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67149. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67150. private _injectVertexCode;
  67151. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67152. serialize(): any;
  67153. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67154. }
  67155. }
  67156. declare module BABYLON {
  67157. /**
  67158. * Block used to read a reflection texture from a sampler
  67159. */
  67160. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67161. /**
  67162. * Create a new ReflectionTextureBlock
  67163. * @param name defines the block name
  67164. */
  67165. constructor(name: string);
  67166. /**
  67167. * Gets the current class name
  67168. * @returns the class name
  67169. */
  67170. getClassName(): string;
  67171. /**
  67172. * Gets the world position input component
  67173. */
  67174. get position(): NodeMaterialConnectionPoint;
  67175. /**
  67176. * Gets the world position input component
  67177. */
  67178. get worldPosition(): NodeMaterialConnectionPoint;
  67179. /**
  67180. * Gets the world normal input component
  67181. */
  67182. get worldNormal(): NodeMaterialConnectionPoint;
  67183. /**
  67184. * Gets the world input component
  67185. */
  67186. get world(): NodeMaterialConnectionPoint;
  67187. /**
  67188. * Gets the camera (or eye) position component
  67189. */
  67190. get cameraPosition(): NodeMaterialConnectionPoint;
  67191. /**
  67192. * Gets the view input component
  67193. */
  67194. get view(): NodeMaterialConnectionPoint;
  67195. /**
  67196. * Gets the rgb output component
  67197. */
  67198. get rgb(): NodeMaterialConnectionPoint;
  67199. /**
  67200. * Gets the rgba output component
  67201. */
  67202. get rgba(): NodeMaterialConnectionPoint;
  67203. /**
  67204. * Gets the r output component
  67205. */
  67206. get r(): NodeMaterialConnectionPoint;
  67207. /**
  67208. * Gets the g output component
  67209. */
  67210. get g(): NodeMaterialConnectionPoint;
  67211. /**
  67212. * Gets the b output component
  67213. */
  67214. get b(): NodeMaterialConnectionPoint;
  67215. /**
  67216. * Gets the a output component
  67217. */
  67218. get a(): NodeMaterialConnectionPoint;
  67219. autoConfigure(material: NodeMaterial): void;
  67220. protected _buildBlock(state: NodeMaterialBuildState): this;
  67221. }
  67222. }
  67223. declare module BABYLON {
  67224. /**
  67225. * Block used to add 2 vectors
  67226. */
  67227. export class AddBlock extends NodeMaterialBlock {
  67228. /**
  67229. * Creates a new AddBlock
  67230. * @param name defines the block name
  67231. */
  67232. constructor(name: string);
  67233. /**
  67234. * Gets the current class name
  67235. * @returns the class name
  67236. */
  67237. getClassName(): string;
  67238. /**
  67239. * Gets the left operand input component
  67240. */
  67241. get left(): NodeMaterialConnectionPoint;
  67242. /**
  67243. * Gets the right operand input component
  67244. */
  67245. get right(): NodeMaterialConnectionPoint;
  67246. /**
  67247. * Gets the output component
  67248. */
  67249. get output(): NodeMaterialConnectionPoint;
  67250. protected _buildBlock(state: NodeMaterialBuildState): this;
  67251. }
  67252. }
  67253. declare module BABYLON {
  67254. /**
  67255. * Block used to scale a vector by a float
  67256. */
  67257. export class ScaleBlock extends NodeMaterialBlock {
  67258. /**
  67259. * Creates a new ScaleBlock
  67260. * @param name defines the block name
  67261. */
  67262. constructor(name: string);
  67263. /**
  67264. * Gets the current class name
  67265. * @returns the class name
  67266. */
  67267. getClassName(): string;
  67268. /**
  67269. * Gets the input component
  67270. */
  67271. get input(): NodeMaterialConnectionPoint;
  67272. /**
  67273. * Gets the factor input component
  67274. */
  67275. get factor(): NodeMaterialConnectionPoint;
  67276. /**
  67277. * Gets the output component
  67278. */
  67279. get output(): NodeMaterialConnectionPoint;
  67280. protected _buildBlock(state: NodeMaterialBuildState): this;
  67281. }
  67282. }
  67283. declare module BABYLON {
  67284. /**
  67285. * Block used to clamp a float
  67286. */
  67287. export class ClampBlock extends NodeMaterialBlock {
  67288. /** Gets or sets the minimum range */
  67289. minimum: number;
  67290. /** Gets or sets the maximum range */
  67291. maximum: number;
  67292. /**
  67293. * Creates a new ClampBlock
  67294. * @param name defines the block name
  67295. */
  67296. constructor(name: string);
  67297. /**
  67298. * Gets the current class name
  67299. * @returns the class name
  67300. */
  67301. getClassName(): string;
  67302. /**
  67303. * Gets the value input component
  67304. */
  67305. get value(): NodeMaterialConnectionPoint;
  67306. /**
  67307. * Gets the output component
  67308. */
  67309. get output(): NodeMaterialConnectionPoint;
  67310. protected _buildBlock(state: NodeMaterialBuildState): this;
  67311. protected _dumpPropertiesCode(): string;
  67312. serialize(): any;
  67313. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67314. }
  67315. }
  67316. declare module BABYLON {
  67317. /**
  67318. * Block used to apply a cross product between 2 vectors
  67319. */
  67320. export class CrossBlock extends NodeMaterialBlock {
  67321. /**
  67322. * Creates a new CrossBlock
  67323. * @param name defines the block name
  67324. */
  67325. constructor(name: string);
  67326. /**
  67327. * Gets the current class name
  67328. * @returns the class name
  67329. */
  67330. getClassName(): string;
  67331. /**
  67332. * Gets the left operand input component
  67333. */
  67334. get left(): NodeMaterialConnectionPoint;
  67335. /**
  67336. * Gets the right operand input component
  67337. */
  67338. get right(): NodeMaterialConnectionPoint;
  67339. /**
  67340. * Gets the output component
  67341. */
  67342. get output(): NodeMaterialConnectionPoint;
  67343. protected _buildBlock(state: NodeMaterialBuildState): this;
  67344. }
  67345. }
  67346. declare module BABYLON {
  67347. /**
  67348. * Block used to apply a dot product between 2 vectors
  67349. */
  67350. export class DotBlock extends NodeMaterialBlock {
  67351. /**
  67352. * Creates a new DotBlock
  67353. * @param name defines the block name
  67354. */
  67355. constructor(name: string);
  67356. /**
  67357. * Gets the current class name
  67358. * @returns the class name
  67359. */
  67360. getClassName(): string;
  67361. /**
  67362. * Gets the left operand input component
  67363. */
  67364. get left(): NodeMaterialConnectionPoint;
  67365. /**
  67366. * Gets the right operand input component
  67367. */
  67368. get right(): NodeMaterialConnectionPoint;
  67369. /**
  67370. * Gets the output component
  67371. */
  67372. get output(): NodeMaterialConnectionPoint;
  67373. protected _buildBlock(state: NodeMaterialBuildState): this;
  67374. }
  67375. }
  67376. declare module BABYLON {
  67377. /**
  67378. * Block used to normalize a vector
  67379. */
  67380. export class NormalizeBlock extends NodeMaterialBlock {
  67381. /**
  67382. * Creates a new NormalizeBlock
  67383. * @param name defines the block name
  67384. */
  67385. constructor(name: string);
  67386. /**
  67387. * Gets the current class name
  67388. * @returns the class name
  67389. */
  67390. getClassName(): string;
  67391. /**
  67392. * Gets the input component
  67393. */
  67394. get input(): NodeMaterialConnectionPoint;
  67395. /**
  67396. * Gets the output component
  67397. */
  67398. get output(): NodeMaterialConnectionPoint;
  67399. protected _buildBlock(state: NodeMaterialBuildState): this;
  67400. }
  67401. }
  67402. declare module BABYLON {
  67403. /**
  67404. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67405. */
  67406. export class ColorMergerBlock extends NodeMaterialBlock {
  67407. /**
  67408. * Create a new ColorMergerBlock
  67409. * @param name defines the block name
  67410. */
  67411. constructor(name: string);
  67412. /**
  67413. * Gets the current class name
  67414. * @returns the class name
  67415. */
  67416. getClassName(): string;
  67417. /**
  67418. * Gets the rgb component (input)
  67419. */
  67420. get rgbIn(): NodeMaterialConnectionPoint;
  67421. /**
  67422. * Gets the r component (input)
  67423. */
  67424. get r(): NodeMaterialConnectionPoint;
  67425. /**
  67426. * Gets the g component (input)
  67427. */
  67428. get g(): NodeMaterialConnectionPoint;
  67429. /**
  67430. * Gets the b component (input)
  67431. */
  67432. get b(): NodeMaterialConnectionPoint;
  67433. /**
  67434. * Gets the a component (input)
  67435. */
  67436. get a(): NodeMaterialConnectionPoint;
  67437. /**
  67438. * Gets the rgba component (output)
  67439. */
  67440. get rgba(): NodeMaterialConnectionPoint;
  67441. /**
  67442. * Gets the rgb component (output)
  67443. */
  67444. get rgbOut(): NodeMaterialConnectionPoint;
  67445. /**
  67446. * Gets the rgb component (output)
  67447. * @deprecated Please use rgbOut instead.
  67448. */
  67449. get rgb(): NodeMaterialConnectionPoint;
  67450. protected _buildBlock(state: NodeMaterialBuildState): this;
  67451. }
  67452. }
  67453. declare module BABYLON {
  67454. /**
  67455. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67456. */
  67457. export class VectorSplitterBlock extends NodeMaterialBlock {
  67458. /**
  67459. * Create a new VectorSplitterBlock
  67460. * @param name defines the block name
  67461. */
  67462. constructor(name: string);
  67463. /**
  67464. * Gets the current class name
  67465. * @returns the class name
  67466. */
  67467. getClassName(): string;
  67468. /**
  67469. * Gets the xyzw component (input)
  67470. */
  67471. get xyzw(): NodeMaterialConnectionPoint;
  67472. /**
  67473. * Gets the xyz component (input)
  67474. */
  67475. get xyzIn(): NodeMaterialConnectionPoint;
  67476. /**
  67477. * Gets the xy component (input)
  67478. */
  67479. get xyIn(): NodeMaterialConnectionPoint;
  67480. /**
  67481. * Gets the xyz component (output)
  67482. */
  67483. get xyzOut(): NodeMaterialConnectionPoint;
  67484. /**
  67485. * Gets the xy component (output)
  67486. */
  67487. get xyOut(): NodeMaterialConnectionPoint;
  67488. /**
  67489. * Gets the x component (output)
  67490. */
  67491. get x(): NodeMaterialConnectionPoint;
  67492. /**
  67493. * Gets the y component (output)
  67494. */
  67495. get y(): NodeMaterialConnectionPoint;
  67496. /**
  67497. * Gets the z component (output)
  67498. */
  67499. get z(): NodeMaterialConnectionPoint;
  67500. /**
  67501. * Gets the w component (output)
  67502. */
  67503. get w(): NodeMaterialConnectionPoint;
  67504. protected _inputRename(name: string): string;
  67505. protected _outputRename(name: string): string;
  67506. protected _buildBlock(state: NodeMaterialBuildState): this;
  67507. }
  67508. }
  67509. declare module BABYLON {
  67510. /**
  67511. * Block used to lerp between 2 values
  67512. */
  67513. export class LerpBlock extends NodeMaterialBlock {
  67514. /**
  67515. * Creates a new LerpBlock
  67516. * @param name defines the block name
  67517. */
  67518. constructor(name: string);
  67519. /**
  67520. * Gets the current class name
  67521. * @returns the class name
  67522. */
  67523. getClassName(): string;
  67524. /**
  67525. * Gets the left operand input component
  67526. */
  67527. get left(): NodeMaterialConnectionPoint;
  67528. /**
  67529. * Gets the right operand input component
  67530. */
  67531. get right(): NodeMaterialConnectionPoint;
  67532. /**
  67533. * Gets the gradient operand input component
  67534. */
  67535. get gradient(): NodeMaterialConnectionPoint;
  67536. /**
  67537. * Gets the output component
  67538. */
  67539. get output(): NodeMaterialConnectionPoint;
  67540. protected _buildBlock(state: NodeMaterialBuildState): this;
  67541. }
  67542. }
  67543. declare module BABYLON {
  67544. /**
  67545. * Block used to divide 2 vectors
  67546. */
  67547. export class DivideBlock extends NodeMaterialBlock {
  67548. /**
  67549. * Creates a new DivideBlock
  67550. * @param name defines the block name
  67551. */
  67552. constructor(name: string);
  67553. /**
  67554. * Gets the current class name
  67555. * @returns the class name
  67556. */
  67557. getClassName(): string;
  67558. /**
  67559. * Gets the left operand input component
  67560. */
  67561. get left(): NodeMaterialConnectionPoint;
  67562. /**
  67563. * Gets the right operand input component
  67564. */
  67565. get right(): NodeMaterialConnectionPoint;
  67566. /**
  67567. * Gets the output component
  67568. */
  67569. get output(): NodeMaterialConnectionPoint;
  67570. protected _buildBlock(state: NodeMaterialBuildState): this;
  67571. }
  67572. }
  67573. declare module BABYLON {
  67574. /**
  67575. * Block used to subtract 2 vectors
  67576. */
  67577. export class SubtractBlock extends NodeMaterialBlock {
  67578. /**
  67579. * Creates a new SubtractBlock
  67580. * @param name defines the block name
  67581. */
  67582. constructor(name: string);
  67583. /**
  67584. * Gets the current class name
  67585. * @returns the class name
  67586. */
  67587. getClassName(): string;
  67588. /**
  67589. * Gets the left operand input component
  67590. */
  67591. get left(): NodeMaterialConnectionPoint;
  67592. /**
  67593. * Gets the right operand input component
  67594. */
  67595. get right(): NodeMaterialConnectionPoint;
  67596. /**
  67597. * Gets the output component
  67598. */
  67599. get output(): NodeMaterialConnectionPoint;
  67600. protected _buildBlock(state: NodeMaterialBuildState): this;
  67601. }
  67602. }
  67603. declare module BABYLON {
  67604. /**
  67605. * Block used to step a value
  67606. */
  67607. export class StepBlock extends NodeMaterialBlock {
  67608. /**
  67609. * Creates a new StepBlock
  67610. * @param name defines the block name
  67611. */
  67612. constructor(name: string);
  67613. /**
  67614. * Gets the current class name
  67615. * @returns the class name
  67616. */
  67617. getClassName(): string;
  67618. /**
  67619. * Gets the value operand input component
  67620. */
  67621. get value(): NodeMaterialConnectionPoint;
  67622. /**
  67623. * Gets the edge operand input component
  67624. */
  67625. get edge(): NodeMaterialConnectionPoint;
  67626. /**
  67627. * Gets the output component
  67628. */
  67629. get output(): NodeMaterialConnectionPoint;
  67630. protected _buildBlock(state: NodeMaterialBuildState): this;
  67631. }
  67632. }
  67633. declare module BABYLON {
  67634. /**
  67635. * Block used to get the opposite (1 - x) of a value
  67636. */
  67637. export class OneMinusBlock extends NodeMaterialBlock {
  67638. /**
  67639. * Creates a new OneMinusBlock
  67640. * @param name defines the block name
  67641. */
  67642. constructor(name: string);
  67643. /**
  67644. * Gets the current class name
  67645. * @returns the class name
  67646. */
  67647. getClassName(): string;
  67648. /**
  67649. * Gets the input component
  67650. */
  67651. get input(): NodeMaterialConnectionPoint;
  67652. /**
  67653. * Gets the output component
  67654. */
  67655. get output(): NodeMaterialConnectionPoint;
  67656. protected _buildBlock(state: NodeMaterialBuildState): this;
  67657. }
  67658. }
  67659. declare module BABYLON {
  67660. /**
  67661. * Block used to get the view direction
  67662. */
  67663. export class ViewDirectionBlock extends NodeMaterialBlock {
  67664. /**
  67665. * Creates a new ViewDirectionBlock
  67666. * @param name defines the block name
  67667. */
  67668. constructor(name: string);
  67669. /**
  67670. * Gets the current class name
  67671. * @returns the class name
  67672. */
  67673. getClassName(): string;
  67674. /**
  67675. * Gets the world position component
  67676. */
  67677. get worldPosition(): NodeMaterialConnectionPoint;
  67678. /**
  67679. * Gets the camera position component
  67680. */
  67681. get cameraPosition(): NodeMaterialConnectionPoint;
  67682. /**
  67683. * Gets the output component
  67684. */
  67685. get output(): NodeMaterialConnectionPoint;
  67686. autoConfigure(material: NodeMaterial): void;
  67687. protected _buildBlock(state: NodeMaterialBuildState): this;
  67688. }
  67689. }
  67690. declare module BABYLON {
  67691. /**
  67692. * Block used to compute fresnel value
  67693. */
  67694. export class FresnelBlock extends NodeMaterialBlock {
  67695. /**
  67696. * Create a new FresnelBlock
  67697. * @param name defines the block name
  67698. */
  67699. constructor(name: string);
  67700. /**
  67701. * Gets the current class name
  67702. * @returns the class name
  67703. */
  67704. getClassName(): string;
  67705. /**
  67706. * Gets the world normal input component
  67707. */
  67708. get worldNormal(): NodeMaterialConnectionPoint;
  67709. /**
  67710. * Gets the view direction input component
  67711. */
  67712. get viewDirection(): NodeMaterialConnectionPoint;
  67713. /**
  67714. * Gets the bias input component
  67715. */
  67716. get bias(): NodeMaterialConnectionPoint;
  67717. /**
  67718. * Gets the camera (or eye) position component
  67719. */
  67720. get power(): NodeMaterialConnectionPoint;
  67721. /**
  67722. * Gets the fresnel output component
  67723. */
  67724. get fresnel(): NodeMaterialConnectionPoint;
  67725. autoConfigure(material: NodeMaterial): void;
  67726. protected _buildBlock(state: NodeMaterialBuildState): this;
  67727. }
  67728. }
  67729. declare module BABYLON {
  67730. /**
  67731. * Block used to get the max of 2 values
  67732. */
  67733. export class MaxBlock extends NodeMaterialBlock {
  67734. /**
  67735. * Creates a new MaxBlock
  67736. * @param name defines the block name
  67737. */
  67738. constructor(name: string);
  67739. /**
  67740. * Gets the current class name
  67741. * @returns the class name
  67742. */
  67743. getClassName(): string;
  67744. /**
  67745. * Gets the left operand input component
  67746. */
  67747. get left(): NodeMaterialConnectionPoint;
  67748. /**
  67749. * Gets the right operand input component
  67750. */
  67751. get right(): NodeMaterialConnectionPoint;
  67752. /**
  67753. * Gets the output component
  67754. */
  67755. get output(): NodeMaterialConnectionPoint;
  67756. protected _buildBlock(state: NodeMaterialBuildState): this;
  67757. }
  67758. }
  67759. declare module BABYLON {
  67760. /**
  67761. * Block used to get the min of 2 values
  67762. */
  67763. export class MinBlock extends NodeMaterialBlock {
  67764. /**
  67765. * Creates a new MinBlock
  67766. * @param name defines the block name
  67767. */
  67768. constructor(name: string);
  67769. /**
  67770. * Gets the current class name
  67771. * @returns the class name
  67772. */
  67773. getClassName(): string;
  67774. /**
  67775. * Gets the left operand input component
  67776. */
  67777. get left(): NodeMaterialConnectionPoint;
  67778. /**
  67779. * Gets the right operand input component
  67780. */
  67781. get right(): NodeMaterialConnectionPoint;
  67782. /**
  67783. * Gets the output component
  67784. */
  67785. get output(): NodeMaterialConnectionPoint;
  67786. protected _buildBlock(state: NodeMaterialBuildState): this;
  67787. }
  67788. }
  67789. declare module BABYLON {
  67790. /**
  67791. * Block used to get the distance between 2 values
  67792. */
  67793. export class DistanceBlock extends NodeMaterialBlock {
  67794. /**
  67795. * Creates a new DistanceBlock
  67796. * @param name defines the block name
  67797. */
  67798. constructor(name: string);
  67799. /**
  67800. * Gets the current class name
  67801. * @returns the class name
  67802. */
  67803. getClassName(): string;
  67804. /**
  67805. * Gets the left operand input component
  67806. */
  67807. get left(): NodeMaterialConnectionPoint;
  67808. /**
  67809. * Gets the right operand input component
  67810. */
  67811. get right(): NodeMaterialConnectionPoint;
  67812. /**
  67813. * Gets the output component
  67814. */
  67815. get output(): NodeMaterialConnectionPoint;
  67816. protected _buildBlock(state: NodeMaterialBuildState): this;
  67817. }
  67818. }
  67819. declare module BABYLON {
  67820. /**
  67821. * Block used to get the length of a vector
  67822. */
  67823. export class LengthBlock extends NodeMaterialBlock {
  67824. /**
  67825. * Creates a new LengthBlock
  67826. * @param name defines the block name
  67827. */
  67828. constructor(name: string);
  67829. /**
  67830. * Gets the current class name
  67831. * @returns the class name
  67832. */
  67833. getClassName(): string;
  67834. /**
  67835. * Gets the value input component
  67836. */
  67837. get value(): NodeMaterialConnectionPoint;
  67838. /**
  67839. * Gets the output component
  67840. */
  67841. get output(): NodeMaterialConnectionPoint;
  67842. protected _buildBlock(state: NodeMaterialBuildState): this;
  67843. }
  67844. }
  67845. declare module BABYLON {
  67846. /**
  67847. * Block used to get negative version of a value (i.e. x * -1)
  67848. */
  67849. export class NegateBlock extends NodeMaterialBlock {
  67850. /**
  67851. * Creates a new NegateBlock
  67852. * @param name defines the block name
  67853. */
  67854. constructor(name: string);
  67855. /**
  67856. * Gets the current class name
  67857. * @returns the class name
  67858. */
  67859. getClassName(): string;
  67860. /**
  67861. * Gets the value input component
  67862. */
  67863. get value(): NodeMaterialConnectionPoint;
  67864. /**
  67865. * Gets the output component
  67866. */
  67867. get output(): NodeMaterialConnectionPoint;
  67868. protected _buildBlock(state: NodeMaterialBuildState): this;
  67869. }
  67870. }
  67871. declare module BABYLON {
  67872. /**
  67873. * Block used to get the value of the first parameter raised to the power of the second
  67874. */
  67875. export class PowBlock extends NodeMaterialBlock {
  67876. /**
  67877. * Creates a new PowBlock
  67878. * @param name defines the block name
  67879. */
  67880. constructor(name: string);
  67881. /**
  67882. * Gets the current class name
  67883. * @returns the class name
  67884. */
  67885. getClassName(): string;
  67886. /**
  67887. * Gets the value operand input component
  67888. */
  67889. get value(): NodeMaterialConnectionPoint;
  67890. /**
  67891. * Gets the power operand input component
  67892. */
  67893. get power(): NodeMaterialConnectionPoint;
  67894. /**
  67895. * Gets the output component
  67896. */
  67897. get output(): NodeMaterialConnectionPoint;
  67898. protected _buildBlock(state: NodeMaterialBuildState): this;
  67899. }
  67900. }
  67901. declare module BABYLON {
  67902. /**
  67903. * Block used to get a random number
  67904. */
  67905. export class RandomNumberBlock extends NodeMaterialBlock {
  67906. /**
  67907. * Creates a new RandomNumberBlock
  67908. * @param name defines the block name
  67909. */
  67910. constructor(name: string);
  67911. /**
  67912. * Gets the current class name
  67913. * @returns the class name
  67914. */
  67915. getClassName(): string;
  67916. /**
  67917. * Gets the seed input component
  67918. */
  67919. get seed(): NodeMaterialConnectionPoint;
  67920. /**
  67921. * Gets the output component
  67922. */
  67923. get output(): NodeMaterialConnectionPoint;
  67924. protected _buildBlock(state: NodeMaterialBuildState): this;
  67925. }
  67926. }
  67927. declare module BABYLON {
  67928. /**
  67929. * Block used to compute arc tangent of 2 values
  67930. */
  67931. export class ArcTan2Block extends NodeMaterialBlock {
  67932. /**
  67933. * Creates a new ArcTan2Block
  67934. * @param name defines the block name
  67935. */
  67936. constructor(name: string);
  67937. /**
  67938. * Gets the current class name
  67939. * @returns the class name
  67940. */
  67941. getClassName(): string;
  67942. /**
  67943. * Gets the x operand input component
  67944. */
  67945. get x(): NodeMaterialConnectionPoint;
  67946. /**
  67947. * Gets the y operand input component
  67948. */
  67949. get y(): NodeMaterialConnectionPoint;
  67950. /**
  67951. * Gets the output component
  67952. */
  67953. get output(): NodeMaterialConnectionPoint;
  67954. protected _buildBlock(state: NodeMaterialBuildState): this;
  67955. }
  67956. }
  67957. declare module BABYLON {
  67958. /**
  67959. * Block used to smooth step a value
  67960. */
  67961. export class SmoothStepBlock extends NodeMaterialBlock {
  67962. /**
  67963. * Creates a new SmoothStepBlock
  67964. * @param name defines the block name
  67965. */
  67966. constructor(name: string);
  67967. /**
  67968. * Gets the current class name
  67969. * @returns the class name
  67970. */
  67971. getClassName(): string;
  67972. /**
  67973. * Gets the value operand input component
  67974. */
  67975. get value(): NodeMaterialConnectionPoint;
  67976. /**
  67977. * Gets the first edge operand input component
  67978. */
  67979. get edge0(): NodeMaterialConnectionPoint;
  67980. /**
  67981. * Gets the second edge operand input component
  67982. */
  67983. get edge1(): NodeMaterialConnectionPoint;
  67984. /**
  67985. * Gets the output component
  67986. */
  67987. get output(): NodeMaterialConnectionPoint;
  67988. protected _buildBlock(state: NodeMaterialBuildState): this;
  67989. }
  67990. }
  67991. declare module BABYLON {
  67992. /**
  67993. * Block used to get the reciprocal (1 / x) of a value
  67994. */
  67995. export class ReciprocalBlock extends NodeMaterialBlock {
  67996. /**
  67997. * Creates a new ReciprocalBlock
  67998. * @param name defines the block name
  67999. */
  68000. constructor(name: string);
  68001. /**
  68002. * Gets the current class name
  68003. * @returns the class name
  68004. */
  68005. getClassName(): string;
  68006. /**
  68007. * Gets the input component
  68008. */
  68009. get input(): NodeMaterialConnectionPoint;
  68010. /**
  68011. * Gets the output component
  68012. */
  68013. get output(): NodeMaterialConnectionPoint;
  68014. protected _buildBlock(state: NodeMaterialBuildState): this;
  68015. }
  68016. }
  68017. declare module BABYLON {
  68018. /**
  68019. * Block used to replace a color by another one
  68020. */
  68021. export class ReplaceColorBlock extends NodeMaterialBlock {
  68022. /**
  68023. * Creates a new ReplaceColorBlock
  68024. * @param name defines the block name
  68025. */
  68026. constructor(name: string);
  68027. /**
  68028. * Gets the current class name
  68029. * @returns the class name
  68030. */
  68031. getClassName(): string;
  68032. /**
  68033. * Gets the value input component
  68034. */
  68035. get value(): NodeMaterialConnectionPoint;
  68036. /**
  68037. * Gets the reference input component
  68038. */
  68039. get reference(): NodeMaterialConnectionPoint;
  68040. /**
  68041. * Gets the distance input component
  68042. */
  68043. get distance(): NodeMaterialConnectionPoint;
  68044. /**
  68045. * Gets the replacement input component
  68046. */
  68047. get replacement(): NodeMaterialConnectionPoint;
  68048. /**
  68049. * Gets the output component
  68050. */
  68051. get output(): NodeMaterialConnectionPoint;
  68052. protected _buildBlock(state: NodeMaterialBuildState): this;
  68053. }
  68054. }
  68055. declare module BABYLON {
  68056. /**
  68057. * Block used to posterize a value
  68058. * @see https://en.wikipedia.org/wiki/Posterization
  68059. */
  68060. export class PosterizeBlock extends NodeMaterialBlock {
  68061. /**
  68062. * Creates a new PosterizeBlock
  68063. * @param name defines the block name
  68064. */
  68065. constructor(name: string);
  68066. /**
  68067. * Gets the current class name
  68068. * @returns the class name
  68069. */
  68070. getClassName(): string;
  68071. /**
  68072. * Gets the value input component
  68073. */
  68074. get value(): NodeMaterialConnectionPoint;
  68075. /**
  68076. * Gets the steps input component
  68077. */
  68078. get steps(): NodeMaterialConnectionPoint;
  68079. /**
  68080. * Gets the output component
  68081. */
  68082. get output(): NodeMaterialConnectionPoint;
  68083. protected _buildBlock(state: NodeMaterialBuildState): this;
  68084. }
  68085. }
  68086. declare module BABYLON {
  68087. /**
  68088. * Operations supported by the Wave block
  68089. */
  68090. export enum WaveBlockKind {
  68091. /** SawTooth */
  68092. SawTooth = 0,
  68093. /** Square */
  68094. Square = 1,
  68095. /** Triangle */
  68096. Triangle = 2
  68097. }
  68098. /**
  68099. * Block used to apply wave operation to floats
  68100. */
  68101. export class WaveBlock extends NodeMaterialBlock {
  68102. /**
  68103. * Gets or sets the kibnd of wave to be applied by the block
  68104. */
  68105. kind: WaveBlockKind;
  68106. /**
  68107. * Creates a new WaveBlock
  68108. * @param name defines the block name
  68109. */
  68110. constructor(name: string);
  68111. /**
  68112. * Gets the current class name
  68113. * @returns the class name
  68114. */
  68115. getClassName(): string;
  68116. /**
  68117. * Gets the input component
  68118. */
  68119. get input(): NodeMaterialConnectionPoint;
  68120. /**
  68121. * Gets the output component
  68122. */
  68123. get output(): NodeMaterialConnectionPoint;
  68124. protected _buildBlock(state: NodeMaterialBuildState): this;
  68125. serialize(): any;
  68126. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68127. }
  68128. }
  68129. declare module BABYLON {
  68130. /**
  68131. * Class used to store a color step for the GradientBlock
  68132. */
  68133. export class GradientBlockColorStep {
  68134. private _step;
  68135. /**
  68136. * Gets value indicating which step this color is associated with (between 0 and 1)
  68137. */
  68138. get step(): number;
  68139. /**
  68140. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68141. */
  68142. set step(val: number);
  68143. private _color;
  68144. /**
  68145. * Gets the color associated with this step
  68146. */
  68147. get color(): Color3;
  68148. /**
  68149. * Sets the color associated with this step
  68150. */
  68151. set color(val: Color3);
  68152. /**
  68153. * Creates a new GradientBlockColorStep
  68154. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68155. * @param color defines the color associated with this step
  68156. */
  68157. constructor(step: number, color: Color3);
  68158. }
  68159. /**
  68160. * Block used to return a color from a gradient based on an input value between 0 and 1
  68161. */
  68162. export class GradientBlock extends NodeMaterialBlock {
  68163. /**
  68164. * Gets or sets the list of color steps
  68165. */
  68166. colorSteps: GradientBlockColorStep[];
  68167. /** Gets an observable raised when the value is changed */
  68168. onValueChangedObservable: Observable<GradientBlock>;
  68169. /** calls observable when the value is changed*/
  68170. colorStepsUpdated(): void;
  68171. /**
  68172. * Creates a new GradientBlock
  68173. * @param name defines the block name
  68174. */
  68175. constructor(name: string);
  68176. /**
  68177. * Gets the current class name
  68178. * @returns the class name
  68179. */
  68180. getClassName(): string;
  68181. /**
  68182. * Gets the gradient input component
  68183. */
  68184. get gradient(): NodeMaterialConnectionPoint;
  68185. /**
  68186. * Gets the output component
  68187. */
  68188. get output(): NodeMaterialConnectionPoint;
  68189. private _writeColorConstant;
  68190. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68191. serialize(): any;
  68192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68193. protected _dumpPropertiesCode(): string;
  68194. }
  68195. }
  68196. declare module BABYLON {
  68197. /**
  68198. * Block used to normalize lerp between 2 values
  68199. */
  68200. export class NLerpBlock extends NodeMaterialBlock {
  68201. /**
  68202. * Creates a new NLerpBlock
  68203. * @param name defines the block name
  68204. */
  68205. constructor(name: string);
  68206. /**
  68207. * Gets the current class name
  68208. * @returns the class name
  68209. */
  68210. getClassName(): string;
  68211. /**
  68212. * Gets the left operand input component
  68213. */
  68214. get left(): NodeMaterialConnectionPoint;
  68215. /**
  68216. * Gets the right operand input component
  68217. */
  68218. get right(): NodeMaterialConnectionPoint;
  68219. /**
  68220. * Gets the gradient operand input component
  68221. */
  68222. get gradient(): NodeMaterialConnectionPoint;
  68223. /**
  68224. * Gets the output component
  68225. */
  68226. get output(): NodeMaterialConnectionPoint;
  68227. protected _buildBlock(state: NodeMaterialBuildState): this;
  68228. }
  68229. }
  68230. declare module BABYLON {
  68231. /**
  68232. * block used to Generate a Worley Noise 3D Noise Pattern
  68233. */
  68234. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68235. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68236. manhattanDistance: boolean;
  68237. /**
  68238. * Creates a new WorleyNoise3DBlock
  68239. * @param name defines the block name
  68240. */
  68241. constructor(name: string);
  68242. /**
  68243. * Gets the current class name
  68244. * @returns the class name
  68245. */
  68246. getClassName(): string;
  68247. /**
  68248. * Gets the seed input component
  68249. */
  68250. get seed(): NodeMaterialConnectionPoint;
  68251. /**
  68252. * Gets the jitter input component
  68253. */
  68254. get jitter(): NodeMaterialConnectionPoint;
  68255. /**
  68256. * Gets the output component
  68257. */
  68258. get output(): NodeMaterialConnectionPoint;
  68259. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68260. /**
  68261. * Exposes the properties to the UI?
  68262. */
  68263. protected _dumpPropertiesCode(): string;
  68264. /**
  68265. * Exposes the properties to the Seralize?
  68266. */
  68267. serialize(): any;
  68268. /**
  68269. * Exposes the properties to the deseralize?
  68270. */
  68271. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68272. }
  68273. }
  68274. declare module BABYLON {
  68275. /**
  68276. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68277. */
  68278. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68279. /**
  68280. * Creates a new SimplexPerlin3DBlock
  68281. * @param name defines the block name
  68282. */
  68283. constructor(name: string);
  68284. /**
  68285. * Gets the current class name
  68286. * @returns the class name
  68287. */
  68288. getClassName(): string;
  68289. /**
  68290. * Gets the seed operand input component
  68291. */
  68292. get seed(): NodeMaterialConnectionPoint;
  68293. /**
  68294. * Gets the output component
  68295. */
  68296. get output(): NodeMaterialConnectionPoint;
  68297. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68298. }
  68299. }
  68300. declare module BABYLON {
  68301. /**
  68302. * Block used to blend normals
  68303. */
  68304. export class NormalBlendBlock extends NodeMaterialBlock {
  68305. /**
  68306. * Creates a new NormalBlendBlock
  68307. * @param name defines the block name
  68308. */
  68309. constructor(name: string);
  68310. /**
  68311. * Gets the current class name
  68312. * @returns the class name
  68313. */
  68314. getClassName(): string;
  68315. /**
  68316. * Gets the first input component
  68317. */
  68318. get normalMap0(): NodeMaterialConnectionPoint;
  68319. /**
  68320. * Gets the second input component
  68321. */
  68322. get normalMap1(): NodeMaterialConnectionPoint;
  68323. /**
  68324. * Gets the output component
  68325. */
  68326. get output(): NodeMaterialConnectionPoint;
  68327. protected _buildBlock(state: NodeMaterialBuildState): this;
  68328. }
  68329. }
  68330. declare module BABYLON {
  68331. /**
  68332. * Block used to rotate a 2d vector by a given angle
  68333. */
  68334. export class Rotate2dBlock extends NodeMaterialBlock {
  68335. /**
  68336. * Creates a new Rotate2dBlock
  68337. * @param name defines the block name
  68338. */
  68339. constructor(name: string);
  68340. /**
  68341. * Gets the current class name
  68342. * @returns the class name
  68343. */
  68344. getClassName(): string;
  68345. /**
  68346. * Gets the input vector
  68347. */
  68348. get input(): NodeMaterialConnectionPoint;
  68349. /**
  68350. * Gets the input angle
  68351. */
  68352. get angle(): NodeMaterialConnectionPoint;
  68353. /**
  68354. * Gets the output component
  68355. */
  68356. get output(): NodeMaterialConnectionPoint;
  68357. autoConfigure(material: NodeMaterial): void;
  68358. protected _buildBlock(state: NodeMaterialBuildState): this;
  68359. }
  68360. }
  68361. declare module BABYLON {
  68362. /**
  68363. * Block used to get the reflected vector from a direction and a normal
  68364. */
  68365. export class ReflectBlock extends NodeMaterialBlock {
  68366. /**
  68367. * Creates a new ReflectBlock
  68368. * @param name defines the block name
  68369. */
  68370. constructor(name: string);
  68371. /**
  68372. * Gets the current class name
  68373. * @returns the class name
  68374. */
  68375. getClassName(): string;
  68376. /**
  68377. * Gets the incident component
  68378. */
  68379. get incident(): NodeMaterialConnectionPoint;
  68380. /**
  68381. * Gets the normal component
  68382. */
  68383. get normal(): NodeMaterialConnectionPoint;
  68384. /**
  68385. * Gets the output component
  68386. */
  68387. get output(): NodeMaterialConnectionPoint;
  68388. protected _buildBlock(state: NodeMaterialBuildState): this;
  68389. }
  68390. }
  68391. declare module BABYLON {
  68392. /**
  68393. * Block used to get the refracted vector from a direction and a normal
  68394. */
  68395. export class RefractBlock extends NodeMaterialBlock {
  68396. /**
  68397. * Creates a new RefractBlock
  68398. * @param name defines the block name
  68399. */
  68400. constructor(name: string);
  68401. /**
  68402. * Gets the current class name
  68403. * @returns the class name
  68404. */
  68405. getClassName(): string;
  68406. /**
  68407. * Gets the incident component
  68408. */
  68409. get incident(): NodeMaterialConnectionPoint;
  68410. /**
  68411. * Gets the normal component
  68412. */
  68413. get normal(): NodeMaterialConnectionPoint;
  68414. /**
  68415. * Gets the index of refraction component
  68416. */
  68417. get ior(): NodeMaterialConnectionPoint;
  68418. /**
  68419. * Gets the output component
  68420. */
  68421. get output(): NodeMaterialConnectionPoint;
  68422. protected _buildBlock(state: NodeMaterialBuildState): this;
  68423. }
  68424. }
  68425. declare module BABYLON {
  68426. /**
  68427. * Block used to desaturate a color
  68428. */
  68429. export class DesaturateBlock extends NodeMaterialBlock {
  68430. /**
  68431. * Creates a new DesaturateBlock
  68432. * @param name defines the block name
  68433. */
  68434. constructor(name: string);
  68435. /**
  68436. * Gets the current class name
  68437. * @returns the class name
  68438. */
  68439. getClassName(): string;
  68440. /**
  68441. * Gets the color operand input component
  68442. */
  68443. get color(): NodeMaterialConnectionPoint;
  68444. /**
  68445. * Gets the level operand input component
  68446. */
  68447. get level(): NodeMaterialConnectionPoint;
  68448. /**
  68449. * Gets the output component
  68450. */
  68451. get output(): NodeMaterialConnectionPoint;
  68452. protected _buildBlock(state: NodeMaterialBuildState): this;
  68453. }
  68454. }
  68455. declare module BABYLON {
  68456. /**
  68457. * Block used to implement the reflection module of the PBR material
  68458. */
  68459. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68460. /** @hidden */
  68461. _defineLODReflectionAlpha: string;
  68462. /** @hidden */
  68463. _defineLinearSpecularReflection: string;
  68464. private _vEnvironmentIrradianceName;
  68465. /** @hidden */
  68466. _vReflectionMicrosurfaceInfosName: string;
  68467. /** @hidden */
  68468. _vReflectionInfosName: string;
  68469. /** @hidden */
  68470. _vReflectionFilteringInfoName: string;
  68471. private _scene;
  68472. /**
  68473. * The properties below are set by the main PBR block prior to calling methods of this class.
  68474. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68475. * It's less burden on the user side in the editor part.
  68476. */
  68477. /** @hidden */
  68478. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68479. /** @hidden */
  68480. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68481. /** @hidden */
  68482. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68483. /** @hidden */
  68484. viewConnectionPoint: NodeMaterialConnectionPoint;
  68485. /**
  68486. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68487. * diffuse part of the IBL.
  68488. */
  68489. useSphericalHarmonics: boolean;
  68490. /**
  68491. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68492. */
  68493. forceIrradianceInFragment: boolean;
  68494. /**
  68495. * Create a new ReflectionBlock
  68496. * @param name defines the block name
  68497. */
  68498. constructor(name: string);
  68499. /**
  68500. * Gets the current class name
  68501. * @returns the class name
  68502. */
  68503. getClassName(): string;
  68504. /**
  68505. * Gets the position input component
  68506. */
  68507. get position(): NodeMaterialConnectionPoint;
  68508. /**
  68509. * Gets the world position input component
  68510. */
  68511. get worldPosition(): NodeMaterialConnectionPoint;
  68512. /**
  68513. * Gets the world normal input component
  68514. */
  68515. get worldNormal(): NodeMaterialConnectionPoint;
  68516. /**
  68517. * Gets the world input component
  68518. */
  68519. get world(): NodeMaterialConnectionPoint;
  68520. /**
  68521. * Gets the camera (or eye) position component
  68522. */
  68523. get cameraPosition(): NodeMaterialConnectionPoint;
  68524. /**
  68525. * Gets the view input component
  68526. */
  68527. get view(): NodeMaterialConnectionPoint;
  68528. /**
  68529. * Gets the color input component
  68530. */
  68531. get color(): NodeMaterialConnectionPoint;
  68532. /**
  68533. * Gets the reflection object output component
  68534. */
  68535. get reflection(): NodeMaterialConnectionPoint;
  68536. /**
  68537. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68538. */
  68539. get hasTexture(): boolean;
  68540. /**
  68541. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68542. */
  68543. get reflectionColor(): string;
  68544. protected _getTexture(): Nullable<BaseTexture>;
  68545. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68547. /**
  68548. * Gets the code to inject in the vertex shader
  68549. * @param state current state of the node material building
  68550. * @returns the shader code
  68551. */
  68552. handleVertexSide(state: NodeMaterialBuildState): string;
  68553. /**
  68554. * Gets the main code of the block (fragment side)
  68555. * @param state current state of the node material building
  68556. * @param normalVarName name of the existing variable corresponding to the normal
  68557. * @returns the shader code
  68558. */
  68559. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68560. protected _buildBlock(state: NodeMaterialBuildState): this;
  68561. protected _dumpPropertiesCode(): string;
  68562. serialize(): any;
  68563. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68564. }
  68565. }
  68566. declare module BABYLON {
  68567. /**
  68568. * Block used to implement the sheen module of the PBR material
  68569. */
  68570. export class SheenBlock extends NodeMaterialBlock {
  68571. /**
  68572. * Create a new SheenBlock
  68573. * @param name defines the block name
  68574. */
  68575. constructor(name: string);
  68576. /**
  68577. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68578. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68579. * making it easier to setup and tweak the effect
  68580. */
  68581. albedoScaling: boolean;
  68582. /**
  68583. * Defines if the sheen is linked to the sheen color.
  68584. */
  68585. linkSheenWithAlbedo: boolean;
  68586. /**
  68587. * Initialize the block and prepare the context for build
  68588. * @param state defines the state that will be used for the build
  68589. */
  68590. initialize(state: NodeMaterialBuildState): void;
  68591. /**
  68592. * Gets the current class name
  68593. * @returns the class name
  68594. */
  68595. getClassName(): string;
  68596. /**
  68597. * Gets the intensity input component
  68598. */
  68599. get intensity(): NodeMaterialConnectionPoint;
  68600. /**
  68601. * Gets the color input component
  68602. */
  68603. get color(): NodeMaterialConnectionPoint;
  68604. /**
  68605. * Gets the roughness input component
  68606. */
  68607. get roughness(): NodeMaterialConnectionPoint;
  68608. /**
  68609. * Gets the sheen object output component
  68610. */
  68611. get sheen(): NodeMaterialConnectionPoint;
  68612. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68613. /**
  68614. * Gets the main code of the block (fragment side)
  68615. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68616. * @returns the shader code
  68617. */
  68618. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68619. protected _buildBlock(state: NodeMaterialBuildState): this;
  68620. protected _dumpPropertiesCode(): string;
  68621. serialize(): any;
  68622. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68623. }
  68624. }
  68625. declare module BABYLON {
  68626. /**
  68627. * Block used to implement the anisotropy module of the PBR material
  68628. */
  68629. export class AnisotropyBlock extends NodeMaterialBlock {
  68630. /**
  68631. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68632. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68633. * It's less burden on the user side in the editor part.
  68634. */
  68635. /** @hidden */
  68636. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68637. /** @hidden */
  68638. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68639. /**
  68640. * Create a new AnisotropyBlock
  68641. * @param name defines the block name
  68642. */
  68643. constructor(name: string);
  68644. /**
  68645. * Initialize the block and prepare the context for build
  68646. * @param state defines the state that will be used for the build
  68647. */
  68648. initialize(state: NodeMaterialBuildState): void;
  68649. /**
  68650. * Gets the current class name
  68651. * @returns the class name
  68652. */
  68653. getClassName(): string;
  68654. /**
  68655. * Gets the intensity input component
  68656. */
  68657. get intensity(): NodeMaterialConnectionPoint;
  68658. /**
  68659. * Gets the direction input component
  68660. */
  68661. get direction(): NodeMaterialConnectionPoint;
  68662. /**
  68663. * Gets the uv input component
  68664. */
  68665. get uv(): NodeMaterialConnectionPoint;
  68666. /**
  68667. * Gets the worldTangent input component
  68668. */
  68669. get worldTangent(): NodeMaterialConnectionPoint;
  68670. /**
  68671. * Gets the anisotropy object output component
  68672. */
  68673. get anisotropy(): NodeMaterialConnectionPoint;
  68674. private _generateTBNSpace;
  68675. /**
  68676. * Gets the main code of the block (fragment side)
  68677. * @param state current state of the node material building
  68678. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68679. * @returns the shader code
  68680. */
  68681. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68682. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68683. protected _buildBlock(state: NodeMaterialBuildState): this;
  68684. }
  68685. }
  68686. declare module BABYLON {
  68687. /**
  68688. * Block used to implement the clear coat module of the PBR material
  68689. */
  68690. export class ClearCoatBlock extends NodeMaterialBlock {
  68691. private _scene;
  68692. /**
  68693. * Create a new ClearCoatBlock
  68694. * @param name defines the block name
  68695. */
  68696. constructor(name: string);
  68697. /**
  68698. * Defines if the F0 value should be remapped to account for the interface change in the material.
  68699. */
  68700. remapF0OnInterfaceChange: boolean;
  68701. /**
  68702. * Initialize the block and prepare the context for build
  68703. * @param state defines the state that will be used for the build
  68704. */
  68705. initialize(state: NodeMaterialBuildState): void;
  68706. /**
  68707. * Gets the current class name
  68708. * @returns the class name
  68709. */
  68710. getClassName(): string;
  68711. /**
  68712. * Gets the intensity input component
  68713. */
  68714. get intensity(): NodeMaterialConnectionPoint;
  68715. /**
  68716. * Gets the roughness input component
  68717. */
  68718. get roughness(): NodeMaterialConnectionPoint;
  68719. /**
  68720. * Gets the ior input component
  68721. */
  68722. get indexOfRefraction(): NodeMaterialConnectionPoint;
  68723. /**
  68724. * Gets the bump texture input component
  68725. */
  68726. get normalMapColor(): NodeMaterialConnectionPoint;
  68727. /**
  68728. * Gets the uv input component
  68729. */
  68730. get uv(): NodeMaterialConnectionPoint;
  68731. /**
  68732. * Gets the tint color input component
  68733. */
  68734. get tintColor(): NodeMaterialConnectionPoint;
  68735. /**
  68736. * Gets the tint "at distance" input component
  68737. */
  68738. get tintAtDistance(): NodeMaterialConnectionPoint;
  68739. /**
  68740. * Gets the tint thickness input component
  68741. */
  68742. get tintThickness(): NodeMaterialConnectionPoint;
  68743. /**
  68744. * Gets the world tangent input component
  68745. */
  68746. get worldTangent(): NodeMaterialConnectionPoint;
  68747. /**
  68748. * Gets the clear coat object output component
  68749. */
  68750. get clearcoat(): NodeMaterialConnectionPoint;
  68751. autoConfigure(material: NodeMaterial): void;
  68752. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68753. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68754. private _generateTBNSpace;
  68755. /**
  68756. * Gets the main code of the block (fragment side)
  68757. * @param state current state of the node material building
  68758. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68759. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68760. * @param worldPosVarName name of the variable holding the world position
  68761. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68762. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68763. * @param worldNormalVarName name of the variable holding the world normal
  68764. * @returns the shader code
  68765. */
  68766. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68767. protected _buildBlock(state: NodeMaterialBuildState): this;
  68768. protected _dumpPropertiesCode(): string;
  68769. serialize(): any;
  68770. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68771. }
  68772. }
  68773. declare module BABYLON {
  68774. /**
  68775. * Block used to implement the sub surface module of the PBR material
  68776. */
  68777. export class SubSurfaceBlock extends NodeMaterialBlock {
  68778. /**
  68779. * Create a new SubSurfaceBlock
  68780. * @param name defines the block name
  68781. */
  68782. constructor(name: string);
  68783. /**
  68784. * Initialize the block and prepare the context for build
  68785. * @param state defines the state that will be used for the build
  68786. */
  68787. initialize(state: NodeMaterialBuildState): void;
  68788. /**
  68789. * Gets the current class name
  68790. * @returns the class name
  68791. */
  68792. getClassName(): string;
  68793. /**
  68794. * Gets the thickness component
  68795. */
  68796. get thickness(): NodeMaterialConnectionPoint;
  68797. /**
  68798. * Gets the tint color input component
  68799. */
  68800. get tintColor(): NodeMaterialConnectionPoint;
  68801. /**
  68802. * Gets the translucency intensity input component
  68803. */
  68804. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68805. /**
  68806. * Gets the translucency diffusion distance input component
  68807. */
  68808. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  68809. /**
  68810. * Gets the refraction object parameters
  68811. */
  68812. get refraction(): NodeMaterialConnectionPoint;
  68813. /**
  68814. * Gets the sub surface object output component
  68815. */
  68816. get subsurface(): NodeMaterialConnectionPoint;
  68817. autoConfigure(material: NodeMaterial): void;
  68818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68819. /**
  68820. * Gets the main code of the block (fragment side)
  68821. * @param state current state of the node material building
  68822. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68823. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68824. * @param worldPosVarName name of the variable holding the world position
  68825. * @returns the shader code
  68826. */
  68827. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68828. protected _buildBlock(state: NodeMaterialBuildState): this;
  68829. }
  68830. }
  68831. declare module BABYLON {
  68832. /**
  68833. * Block used to implement the PBR metallic/roughness model
  68834. */
  68835. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68836. /**
  68837. * Gets or sets the light associated with this block
  68838. */
  68839. light: Nullable<Light>;
  68840. private _lightId;
  68841. private _scene;
  68842. private _environmentBRDFTexture;
  68843. private _environmentBrdfSamplerName;
  68844. private _vNormalWName;
  68845. private _invertNormalName;
  68846. private _metallicReflectanceColor;
  68847. private _metallicF0Factor;
  68848. private _vMetallicReflectanceFactorsName;
  68849. /**
  68850. * Create a new ReflectionBlock
  68851. * @param name defines the block name
  68852. */
  68853. constructor(name: string);
  68854. /**
  68855. * Intensity of the direct lights e.g. the four lights available in your scene.
  68856. * This impacts both the direct diffuse and specular highlights.
  68857. */
  68858. directIntensity: number;
  68859. /**
  68860. * Intensity of the environment e.g. how much the environment will light the object
  68861. * either through harmonics for rough material or through the refelction for shiny ones.
  68862. */
  68863. environmentIntensity: number;
  68864. /**
  68865. * This is a special control allowing the reduction of the specular highlights coming from the
  68866. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68867. */
  68868. specularIntensity: number;
  68869. /**
  68870. * Defines the falloff type used in this material.
  68871. * It by default is Physical.
  68872. */
  68873. lightFalloff: number;
  68874. /**
  68875. * Specifies that alpha test should be used
  68876. */
  68877. useAlphaTest: boolean;
  68878. /**
  68879. * Defines the alpha limits in alpha test mode.
  68880. */
  68881. alphaTestCutoff: number;
  68882. /**
  68883. * Specifies that alpha blending should be used
  68884. */
  68885. useAlphaBlending: boolean;
  68886. /**
  68887. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68888. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68889. */
  68890. useRadianceOverAlpha: boolean;
  68891. /**
  68892. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68893. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68894. */
  68895. useSpecularOverAlpha: boolean;
  68896. /**
  68897. * Enables specular anti aliasing in the PBR shader.
  68898. * It will both interacts on the Geometry for analytical and IBL lighting.
  68899. * It also prefilter the roughness map based on the bump values.
  68900. */
  68901. enableSpecularAntiAliasing: boolean;
  68902. /**
  68903. * Enables realtime filtering on the texture.
  68904. */
  68905. realTimeFiltering: boolean;
  68906. /**
  68907. * Quality switch for realtime filtering
  68908. */
  68909. realTimeFilteringQuality: number;
  68910. /**
  68911. * Defines if the material uses energy conservation.
  68912. */
  68913. useEnergyConservation: boolean;
  68914. /**
  68915. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68916. * too much the area relying on ambient texture to define their ambient occlusion.
  68917. */
  68918. useRadianceOcclusion: boolean;
  68919. /**
  68920. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68921. * makes the reflect vector face the model (under horizon).
  68922. */
  68923. useHorizonOcclusion: boolean;
  68924. /**
  68925. * If set to true, no lighting calculations will be applied.
  68926. */
  68927. unlit: boolean;
  68928. /**
  68929. * Force normal to face away from face.
  68930. */
  68931. forceNormalForward: boolean;
  68932. /**
  68933. * Defines the material debug mode.
  68934. * It helps seeing only some components of the material while troubleshooting.
  68935. */
  68936. debugMode: number;
  68937. /**
  68938. * Specify from where on screen the debug mode should start.
  68939. * The value goes from -1 (full screen) to 1 (not visible)
  68940. * It helps with side by side comparison against the final render
  68941. * This defaults to 0
  68942. */
  68943. debugLimit: number;
  68944. /**
  68945. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68946. * You can use the factor to better multiply the final value.
  68947. */
  68948. debugFactor: number;
  68949. /**
  68950. * Initialize the block and prepare the context for build
  68951. * @param state defines the state that will be used for the build
  68952. */
  68953. initialize(state: NodeMaterialBuildState): void;
  68954. /**
  68955. * Gets the current class name
  68956. * @returns the class name
  68957. */
  68958. getClassName(): string;
  68959. /**
  68960. * Gets the world position input component
  68961. */
  68962. get worldPosition(): NodeMaterialConnectionPoint;
  68963. /**
  68964. * Gets the world normal input component
  68965. */
  68966. get worldNormal(): NodeMaterialConnectionPoint;
  68967. /**
  68968. * Gets the view matrix parameter
  68969. */
  68970. get view(): NodeMaterialConnectionPoint;
  68971. /**
  68972. * Gets the camera position input component
  68973. */
  68974. get cameraPosition(): NodeMaterialConnectionPoint;
  68975. /**
  68976. * Gets the perturbed normal input component
  68977. */
  68978. get perturbedNormal(): NodeMaterialConnectionPoint;
  68979. /**
  68980. * Gets the base color input component
  68981. */
  68982. get baseColor(): NodeMaterialConnectionPoint;
  68983. /**
  68984. * Gets the metallic input component
  68985. */
  68986. get metallic(): NodeMaterialConnectionPoint;
  68987. /**
  68988. * Gets the roughness input component
  68989. */
  68990. get roughness(): NodeMaterialConnectionPoint;
  68991. /**
  68992. * Gets the ambient occlusion input component
  68993. */
  68994. get ambientOcc(): NodeMaterialConnectionPoint;
  68995. /**
  68996. * Gets the opacity input component
  68997. */
  68998. get opacity(): NodeMaterialConnectionPoint;
  68999. /**
  69000. * Gets the index of refraction input component
  69001. */
  69002. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69003. /**
  69004. * Gets the ambient color input component
  69005. */
  69006. get ambientColor(): NodeMaterialConnectionPoint;
  69007. /**
  69008. * Gets the reflection object parameters
  69009. */
  69010. get reflection(): NodeMaterialConnectionPoint;
  69011. /**
  69012. * Gets the clear coat object parameters
  69013. */
  69014. get clearcoat(): NodeMaterialConnectionPoint;
  69015. /**
  69016. * Gets the sheen object parameters
  69017. */
  69018. get sheen(): NodeMaterialConnectionPoint;
  69019. /**
  69020. * Gets the sub surface object parameters
  69021. */
  69022. get subsurface(): NodeMaterialConnectionPoint;
  69023. /**
  69024. * Gets the anisotropy object parameters
  69025. */
  69026. get anisotropy(): NodeMaterialConnectionPoint;
  69027. /**
  69028. * Gets the ambient output component
  69029. */
  69030. get ambientClr(): NodeMaterialConnectionPoint;
  69031. /**
  69032. * Gets the diffuse output component
  69033. */
  69034. get diffuseDir(): NodeMaterialConnectionPoint;
  69035. /**
  69036. * Gets the specular output component
  69037. */
  69038. get specularDir(): NodeMaterialConnectionPoint;
  69039. /**
  69040. * Gets the clear coat output component
  69041. */
  69042. get clearcoatDir(): NodeMaterialConnectionPoint;
  69043. /**
  69044. * Gets the sheen output component
  69045. */
  69046. get sheenDir(): NodeMaterialConnectionPoint;
  69047. /**
  69048. * Gets the indirect diffuse output component
  69049. */
  69050. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69051. /**
  69052. * Gets the indirect specular output component
  69053. */
  69054. get specularIndirect(): NodeMaterialConnectionPoint;
  69055. /**
  69056. * Gets the indirect clear coat output component
  69057. */
  69058. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69059. /**
  69060. * Gets the indirect sheen output component
  69061. */
  69062. get sheenIndirect(): NodeMaterialConnectionPoint;
  69063. /**
  69064. * Gets the refraction output component
  69065. */
  69066. get refraction(): NodeMaterialConnectionPoint;
  69067. /**
  69068. * Gets the global lighting output component
  69069. */
  69070. get lighting(): NodeMaterialConnectionPoint;
  69071. /**
  69072. * Gets the shadow output component
  69073. */
  69074. get shadow(): NodeMaterialConnectionPoint;
  69075. /**
  69076. * Gets the alpha output component
  69077. */
  69078. get alpha(): NodeMaterialConnectionPoint;
  69079. autoConfigure(material: NodeMaterial): void;
  69080. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69081. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69082. isReady(): boolean;
  69083. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69084. private _injectVertexCode;
  69085. private _getAlbedoOpacityCode;
  69086. private _getAmbientOcclusionCode;
  69087. private _getReflectivityCode;
  69088. protected _buildBlock(state: NodeMaterialBuildState): this;
  69089. protected _dumpPropertiesCode(): string;
  69090. serialize(): any;
  69091. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69092. }
  69093. }
  69094. declare module BABYLON {
  69095. /**
  69096. * Block used to compute value of one parameter modulo another
  69097. */
  69098. export class ModBlock extends NodeMaterialBlock {
  69099. /**
  69100. * Creates a new ModBlock
  69101. * @param name defines the block name
  69102. */
  69103. constructor(name: string);
  69104. /**
  69105. * Gets the current class name
  69106. * @returns the class name
  69107. */
  69108. getClassName(): string;
  69109. /**
  69110. * Gets the left operand input component
  69111. */
  69112. get left(): NodeMaterialConnectionPoint;
  69113. /**
  69114. * Gets the right operand input component
  69115. */
  69116. get right(): NodeMaterialConnectionPoint;
  69117. /**
  69118. * Gets the output component
  69119. */
  69120. get output(): NodeMaterialConnectionPoint;
  69121. protected _buildBlock(state: NodeMaterialBuildState): this;
  69122. }
  69123. }
  69124. declare module BABYLON {
  69125. /**
  69126. * Configuration for Draco compression
  69127. */
  69128. export interface IDracoCompressionConfiguration {
  69129. /**
  69130. * Configuration for the decoder.
  69131. */
  69132. decoder: {
  69133. /**
  69134. * The url to the WebAssembly module.
  69135. */
  69136. wasmUrl?: string;
  69137. /**
  69138. * The url to the WebAssembly binary.
  69139. */
  69140. wasmBinaryUrl?: string;
  69141. /**
  69142. * The url to the fallback JavaScript module.
  69143. */
  69144. fallbackUrl?: string;
  69145. };
  69146. }
  69147. /**
  69148. * Draco compression (https://google.github.io/draco/)
  69149. *
  69150. * This class wraps the Draco module.
  69151. *
  69152. * **Encoder**
  69153. *
  69154. * The encoder is not currently implemented.
  69155. *
  69156. * **Decoder**
  69157. *
  69158. * 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.
  69159. *
  69160. * To update the configuration, use the following code:
  69161. * ```javascript
  69162. * DracoCompression.Configuration = {
  69163. * decoder: {
  69164. * wasmUrl: "<url to the WebAssembly library>",
  69165. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69166. * fallbackUrl: "<url to the fallback JavaScript library>",
  69167. * }
  69168. * };
  69169. * ```
  69170. *
  69171. * 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.
  69172. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69173. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69174. *
  69175. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69176. * ```javascript
  69177. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69178. * ```
  69179. *
  69180. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69181. */
  69182. export class DracoCompression implements IDisposable {
  69183. private _workerPoolPromise?;
  69184. private _decoderModulePromise?;
  69185. /**
  69186. * The configuration. Defaults to the following urls:
  69187. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69188. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69189. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69190. */
  69191. static Configuration: IDracoCompressionConfiguration;
  69192. /**
  69193. * Returns true if the decoder configuration is available.
  69194. */
  69195. static get DecoderAvailable(): boolean;
  69196. /**
  69197. * Default number of workers to create when creating the draco compression object.
  69198. */
  69199. static DefaultNumWorkers: number;
  69200. private static GetDefaultNumWorkers;
  69201. private static _Default;
  69202. /**
  69203. * Default instance for the draco compression object.
  69204. */
  69205. static get Default(): DracoCompression;
  69206. /**
  69207. * Constructor
  69208. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69209. */
  69210. constructor(numWorkers?: number);
  69211. /**
  69212. * Stop all async operations and release resources.
  69213. */
  69214. dispose(): void;
  69215. /**
  69216. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69217. * @returns a promise that resolves when ready
  69218. */
  69219. whenReadyAsync(): Promise<void>;
  69220. /**
  69221. * Decode Draco compressed mesh data to vertex data.
  69222. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69223. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69224. * @returns A promise that resolves with the decoded vertex data
  69225. */
  69226. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69227. [kind: string]: number;
  69228. }): Promise<VertexData>;
  69229. }
  69230. }
  69231. declare module BABYLON {
  69232. /**
  69233. * Class for building Constructive Solid Geometry
  69234. */
  69235. export class CSG {
  69236. private polygons;
  69237. /**
  69238. * The world matrix
  69239. */
  69240. matrix: Matrix;
  69241. /**
  69242. * Stores the position
  69243. */
  69244. position: Vector3;
  69245. /**
  69246. * Stores the rotation
  69247. */
  69248. rotation: Vector3;
  69249. /**
  69250. * Stores the rotation quaternion
  69251. */
  69252. rotationQuaternion: Nullable<Quaternion>;
  69253. /**
  69254. * Stores the scaling vector
  69255. */
  69256. scaling: Vector3;
  69257. /**
  69258. * Convert the Mesh to CSG
  69259. * @param mesh The Mesh to convert to CSG
  69260. * @returns A new CSG from the Mesh
  69261. */
  69262. static FromMesh(mesh: Mesh): CSG;
  69263. /**
  69264. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69265. * @param polygons Polygons used to construct a CSG solid
  69266. */
  69267. private static FromPolygons;
  69268. /**
  69269. * Clones, or makes a deep copy, of the CSG
  69270. * @returns A new CSG
  69271. */
  69272. clone(): CSG;
  69273. /**
  69274. * Unions this CSG with another CSG
  69275. * @param csg The CSG to union against this CSG
  69276. * @returns The unioned CSG
  69277. */
  69278. union(csg: CSG): CSG;
  69279. /**
  69280. * Unions this CSG with another CSG in place
  69281. * @param csg The CSG to union against this CSG
  69282. */
  69283. unionInPlace(csg: CSG): void;
  69284. /**
  69285. * Subtracts this CSG with another CSG
  69286. * @param csg The CSG to subtract against this CSG
  69287. * @returns A new CSG
  69288. */
  69289. subtract(csg: CSG): CSG;
  69290. /**
  69291. * Subtracts this CSG with another CSG in place
  69292. * @param csg The CSG to subtact against this CSG
  69293. */
  69294. subtractInPlace(csg: CSG): void;
  69295. /**
  69296. * Intersect this CSG with another CSG
  69297. * @param csg The CSG to intersect against this CSG
  69298. * @returns A new CSG
  69299. */
  69300. intersect(csg: CSG): CSG;
  69301. /**
  69302. * Intersects this CSG with another CSG in place
  69303. * @param csg The CSG to intersect against this CSG
  69304. */
  69305. intersectInPlace(csg: CSG): void;
  69306. /**
  69307. * Return a new CSG solid with solid and empty space switched. This solid is
  69308. * not modified.
  69309. * @returns A new CSG solid with solid and empty space switched
  69310. */
  69311. inverse(): CSG;
  69312. /**
  69313. * Inverses the CSG in place
  69314. */
  69315. inverseInPlace(): void;
  69316. /**
  69317. * This is used to keep meshes transformations so they can be restored
  69318. * when we build back a Babylon Mesh
  69319. * NB : All CSG operations are performed in world coordinates
  69320. * @param csg The CSG to copy the transform attributes from
  69321. * @returns This CSG
  69322. */
  69323. copyTransformAttributes(csg: CSG): CSG;
  69324. /**
  69325. * Build Raw mesh from CSG
  69326. * Coordinates here are in world space
  69327. * @param name The name of the mesh geometry
  69328. * @param scene The Scene
  69329. * @param keepSubMeshes Specifies if the submeshes should be kept
  69330. * @returns A new Mesh
  69331. */
  69332. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69333. /**
  69334. * Build Mesh from CSG taking material and transforms into account
  69335. * @param name The name of the Mesh
  69336. * @param material The material of the Mesh
  69337. * @param scene The Scene
  69338. * @param keepSubMeshes Specifies if submeshes should be kept
  69339. * @returns The new Mesh
  69340. */
  69341. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69342. }
  69343. }
  69344. declare module BABYLON {
  69345. /**
  69346. * Class used to create a trail following a mesh
  69347. */
  69348. export class TrailMesh extends Mesh {
  69349. private _generator;
  69350. private _autoStart;
  69351. private _running;
  69352. private _diameter;
  69353. private _length;
  69354. private _sectionPolygonPointsCount;
  69355. private _sectionVectors;
  69356. private _sectionNormalVectors;
  69357. private _beforeRenderObserver;
  69358. /**
  69359. * @constructor
  69360. * @param name The value used by scene.getMeshByName() to do a lookup.
  69361. * @param generator The mesh or transform node to generate a trail.
  69362. * @param scene The scene to add this mesh to.
  69363. * @param diameter Diameter of trailing mesh. Default is 1.
  69364. * @param length Length of trailing mesh. Default is 60.
  69365. * @param autoStart Automatically start trailing mesh. Default true.
  69366. */
  69367. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69368. /**
  69369. * "TrailMesh"
  69370. * @returns "TrailMesh"
  69371. */
  69372. getClassName(): string;
  69373. private _createMesh;
  69374. /**
  69375. * Start trailing mesh.
  69376. */
  69377. start(): void;
  69378. /**
  69379. * Stop trailing mesh.
  69380. */
  69381. stop(): void;
  69382. /**
  69383. * Update trailing mesh geometry.
  69384. */
  69385. update(): void;
  69386. /**
  69387. * Returns a new TrailMesh object.
  69388. * @param name is a string, the name given to the new mesh
  69389. * @param newGenerator use new generator object for cloned trail mesh
  69390. * @returns a new mesh
  69391. */
  69392. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69393. /**
  69394. * Serializes this trail mesh
  69395. * @param serializationObject object to write serialization to
  69396. */
  69397. serialize(serializationObject: any): void;
  69398. /**
  69399. * Parses a serialized trail mesh
  69400. * @param parsedMesh the serialized mesh
  69401. * @param scene the scene to create the trail mesh in
  69402. * @returns the created trail mesh
  69403. */
  69404. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69405. }
  69406. }
  69407. declare module BABYLON {
  69408. /**
  69409. * Class containing static functions to help procedurally build meshes
  69410. */
  69411. export class TiledBoxBuilder {
  69412. /**
  69413. * Creates a box mesh
  69414. * 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)
  69415. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69417. * * 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
  69418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69419. * @param name defines the name of the mesh
  69420. * @param options defines the options used to create the mesh
  69421. * @param scene defines the hosting scene
  69422. * @returns the box mesh
  69423. */
  69424. static CreateTiledBox(name: string, options: {
  69425. pattern?: number;
  69426. width?: number;
  69427. height?: number;
  69428. depth?: number;
  69429. tileSize?: number;
  69430. tileWidth?: number;
  69431. tileHeight?: number;
  69432. alignHorizontal?: number;
  69433. alignVertical?: number;
  69434. faceUV?: Vector4[];
  69435. faceColors?: Color4[];
  69436. sideOrientation?: number;
  69437. updatable?: boolean;
  69438. }, scene?: Nullable<Scene>): Mesh;
  69439. }
  69440. }
  69441. declare module BABYLON {
  69442. /**
  69443. * Class containing static functions to help procedurally build meshes
  69444. */
  69445. export class TorusKnotBuilder {
  69446. /**
  69447. * Creates a torus knot mesh
  69448. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69449. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69450. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69451. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69453. * * 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
  69454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69455. * @param name defines the name of the mesh
  69456. * @param options defines the options used to create the mesh
  69457. * @param scene defines the hosting scene
  69458. * @returns the torus knot mesh
  69459. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69460. */
  69461. static CreateTorusKnot(name: string, options: {
  69462. radius?: number;
  69463. tube?: number;
  69464. radialSegments?: number;
  69465. tubularSegments?: number;
  69466. p?: number;
  69467. q?: number;
  69468. updatable?: boolean;
  69469. sideOrientation?: number;
  69470. frontUVs?: Vector4;
  69471. backUVs?: Vector4;
  69472. }, scene: any): Mesh;
  69473. }
  69474. }
  69475. declare module BABYLON {
  69476. /**
  69477. * Polygon
  69478. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69479. */
  69480. export class Polygon {
  69481. /**
  69482. * Creates a rectangle
  69483. * @param xmin bottom X coord
  69484. * @param ymin bottom Y coord
  69485. * @param xmax top X coord
  69486. * @param ymax top Y coord
  69487. * @returns points that make the resulting rectation
  69488. */
  69489. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69490. /**
  69491. * Creates a circle
  69492. * @param radius radius of circle
  69493. * @param cx scale in x
  69494. * @param cy scale in y
  69495. * @param numberOfSides number of sides that make up the circle
  69496. * @returns points that make the resulting circle
  69497. */
  69498. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69499. /**
  69500. * Creates a polygon from input string
  69501. * @param input Input polygon data
  69502. * @returns the parsed points
  69503. */
  69504. static Parse(input: string): Vector2[];
  69505. /**
  69506. * Starts building a polygon from x and y coordinates
  69507. * @param x x coordinate
  69508. * @param y y coordinate
  69509. * @returns the started path2
  69510. */
  69511. static StartingAt(x: number, y: number): Path2;
  69512. }
  69513. /**
  69514. * Builds a polygon
  69515. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69516. */
  69517. export class PolygonMeshBuilder {
  69518. private _points;
  69519. private _outlinepoints;
  69520. private _holes;
  69521. private _name;
  69522. private _scene;
  69523. private _epoints;
  69524. private _eholes;
  69525. private _addToepoint;
  69526. /**
  69527. * Babylon reference to the earcut plugin.
  69528. */
  69529. bjsEarcut: any;
  69530. /**
  69531. * Creates a PolygonMeshBuilder
  69532. * @param name name of the builder
  69533. * @param contours Path of the polygon
  69534. * @param scene scene to add to when creating the mesh
  69535. * @param earcutInjection can be used to inject your own earcut reference
  69536. */
  69537. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69538. /**
  69539. * Adds a whole within the polygon
  69540. * @param hole Array of points defining the hole
  69541. * @returns this
  69542. */
  69543. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69544. /**
  69545. * Creates the polygon
  69546. * @param updatable If the mesh should be updatable
  69547. * @param depth The depth of the mesh created
  69548. * @returns the created mesh
  69549. */
  69550. build(updatable?: boolean, depth?: number): Mesh;
  69551. /**
  69552. * Creates the polygon
  69553. * @param depth The depth of the mesh created
  69554. * @returns the created VertexData
  69555. */
  69556. buildVertexData(depth?: number): VertexData;
  69557. /**
  69558. * Adds a side to the polygon
  69559. * @param positions points that make the polygon
  69560. * @param normals normals of the polygon
  69561. * @param uvs uvs of the polygon
  69562. * @param indices indices of the polygon
  69563. * @param bounds bounds of the polygon
  69564. * @param points points of the polygon
  69565. * @param depth depth of the polygon
  69566. * @param flip flip of the polygon
  69567. */
  69568. private addSide;
  69569. }
  69570. }
  69571. declare module BABYLON {
  69572. /**
  69573. * Class containing static functions to help procedurally build meshes
  69574. */
  69575. export class PolygonBuilder {
  69576. /**
  69577. * Creates a polygon mesh
  69578. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69579. * * 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
  69580. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69582. * * 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)
  69583. * * Remember you can only change the shape positions, not their number when updating a polygon
  69584. * @param name defines the name of the mesh
  69585. * @param options defines the options used to create the mesh
  69586. * @param scene defines the hosting scene
  69587. * @param earcutInjection can be used to inject your own earcut reference
  69588. * @returns the polygon mesh
  69589. */
  69590. static CreatePolygon(name: string, options: {
  69591. shape: Vector3[];
  69592. holes?: Vector3[][];
  69593. depth?: number;
  69594. faceUV?: Vector4[];
  69595. faceColors?: Color4[];
  69596. updatable?: boolean;
  69597. sideOrientation?: number;
  69598. frontUVs?: Vector4;
  69599. backUVs?: Vector4;
  69600. wrap?: boolean;
  69601. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69602. /**
  69603. * Creates an extruded polygon mesh, with depth in the Y direction.
  69604. * * 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)
  69605. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69606. * @param name defines the name of the mesh
  69607. * @param options defines the options used to create the mesh
  69608. * @param scene defines the hosting scene
  69609. * @param earcutInjection can be used to inject your own earcut reference
  69610. * @returns the polygon mesh
  69611. */
  69612. static ExtrudePolygon(name: string, options: {
  69613. shape: Vector3[];
  69614. holes?: Vector3[][];
  69615. depth?: number;
  69616. faceUV?: Vector4[];
  69617. faceColors?: Color4[];
  69618. updatable?: boolean;
  69619. sideOrientation?: number;
  69620. frontUVs?: Vector4;
  69621. backUVs?: Vector4;
  69622. wrap?: boolean;
  69623. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69624. }
  69625. }
  69626. declare module BABYLON {
  69627. /**
  69628. * Class containing static functions to help procedurally build meshes
  69629. */
  69630. export class LatheBuilder {
  69631. /**
  69632. * Creates lathe mesh.
  69633. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69634. * * 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
  69635. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69636. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69637. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69638. * * 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
  69639. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69640. * * 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
  69641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69642. * * 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
  69643. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69645. * @param name defines the name of the mesh
  69646. * @param options defines the options used to create the mesh
  69647. * @param scene defines the hosting scene
  69648. * @returns the lathe mesh
  69649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69650. */
  69651. static CreateLathe(name: string, options: {
  69652. shape: Vector3[];
  69653. radius?: number;
  69654. tessellation?: number;
  69655. clip?: number;
  69656. arc?: number;
  69657. closed?: boolean;
  69658. updatable?: boolean;
  69659. sideOrientation?: number;
  69660. frontUVs?: Vector4;
  69661. backUVs?: Vector4;
  69662. cap?: number;
  69663. invertUV?: boolean;
  69664. }, scene?: Nullable<Scene>): Mesh;
  69665. }
  69666. }
  69667. declare module BABYLON {
  69668. /**
  69669. * Class containing static functions to help procedurally build meshes
  69670. */
  69671. export class TiledPlaneBuilder {
  69672. /**
  69673. * Creates a tiled plane mesh
  69674. * * The parameter `pattern` will, depending on value, do nothing or
  69675. * * * flip (reflect about central vertical) alternate tiles across and up
  69676. * * * flip every tile on alternate rows
  69677. * * * rotate (180 degs) alternate tiles across and up
  69678. * * * rotate every tile on alternate rows
  69679. * * * flip and rotate alternate tiles across and up
  69680. * * * flip and rotate every tile on alternate rows
  69681. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69682. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69683. * * 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
  69684. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69685. * * 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)
  69686. * * 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)
  69687. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69688. * @param name defines the name of the mesh
  69689. * @param options defines the options used to create the mesh
  69690. * @param scene defines the hosting scene
  69691. * @returns the box mesh
  69692. */
  69693. static CreateTiledPlane(name: string, options: {
  69694. pattern?: number;
  69695. tileSize?: number;
  69696. tileWidth?: number;
  69697. tileHeight?: number;
  69698. size?: number;
  69699. width?: number;
  69700. height?: number;
  69701. alignHorizontal?: number;
  69702. alignVertical?: number;
  69703. sideOrientation?: number;
  69704. frontUVs?: Vector4;
  69705. backUVs?: Vector4;
  69706. updatable?: boolean;
  69707. }, scene?: Nullable<Scene>): Mesh;
  69708. }
  69709. }
  69710. declare module BABYLON {
  69711. /**
  69712. * Class containing static functions to help procedurally build meshes
  69713. */
  69714. export class TubeBuilder {
  69715. /**
  69716. * Creates a tube mesh.
  69717. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69718. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69719. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69720. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69721. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69722. * * 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)
  69723. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69724. * * 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
  69725. * * 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
  69726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69727. * * 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
  69728. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69730. * @param name defines the name of the mesh
  69731. * @param options defines the options used to create the mesh
  69732. * @param scene defines the hosting scene
  69733. * @returns the tube mesh
  69734. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69735. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69736. */
  69737. static CreateTube(name: string, options: {
  69738. path: Vector3[];
  69739. radius?: number;
  69740. tessellation?: number;
  69741. radiusFunction?: {
  69742. (i: number, distance: number): number;
  69743. };
  69744. cap?: number;
  69745. arc?: number;
  69746. updatable?: boolean;
  69747. sideOrientation?: number;
  69748. frontUVs?: Vector4;
  69749. backUVs?: Vector4;
  69750. instance?: Mesh;
  69751. invertUV?: boolean;
  69752. }, scene?: Nullable<Scene>): Mesh;
  69753. }
  69754. }
  69755. declare module BABYLON {
  69756. /**
  69757. * Class containing static functions to help procedurally build meshes
  69758. */
  69759. export class IcoSphereBuilder {
  69760. /**
  69761. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69762. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69763. * * 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`)
  69764. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69765. * * 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
  69766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69767. * * 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
  69768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69769. * @param name defines the name of the mesh
  69770. * @param options defines the options used to create the mesh
  69771. * @param scene defines the hosting scene
  69772. * @returns the icosahedron mesh
  69773. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69774. */
  69775. static CreateIcoSphere(name: string, options: {
  69776. radius?: number;
  69777. radiusX?: number;
  69778. radiusY?: number;
  69779. radiusZ?: number;
  69780. flat?: boolean;
  69781. subdivisions?: number;
  69782. sideOrientation?: number;
  69783. frontUVs?: Vector4;
  69784. backUVs?: Vector4;
  69785. updatable?: boolean;
  69786. }, scene?: Nullable<Scene>): Mesh;
  69787. }
  69788. }
  69789. declare module BABYLON {
  69790. /**
  69791. * Class containing static functions to help procedurally build meshes
  69792. */
  69793. export class DecalBuilder {
  69794. /**
  69795. * Creates a decal mesh.
  69796. * 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
  69797. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69798. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69799. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69800. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69801. * @param name defines the name of the mesh
  69802. * @param sourceMesh defines the mesh where the decal must be applied
  69803. * @param options defines the options used to create the mesh
  69804. * @param scene defines the hosting scene
  69805. * @returns the decal mesh
  69806. * @see https://doc.babylonjs.com/how_to/decals
  69807. */
  69808. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69809. position?: Vector3;
  69810. normal?: Vector3;
  69811. size?: Vector3;
  69812. angle?: number;
  69813. }): Mesh;
  69814. }
  69815. }
  69816. declare module BABYLON {
  69817. /**
  69818. * Class containing static functions to help procedurally build meshes
  69819. */
  69820. export class MeshBuilder {
  69821. /**
  69822. * Creates a box mesh
  69823. * * The parameter `size` sets the size (float) of each box side (default 1)
  69824. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69825. * * 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)
  69826. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69828. * * 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
  69829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69830. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69831. * @param name defines the name of the mesh
  69832. * @param options defines the options used to create the mesh
  69833. * @param scene defines the hosting scene
  69834. * @returns the box mesh
  69835. */
  69836. static CreateBox(name: string, options: {
  69837. size?: number;
  69838. width?: number;
  69839. height?: number;
  69840. depth?: number;
  69841. faceUV?: Vector4[];
  69842. faceColors?: Color4[];
  69843. sideOrientation?: number;
  69844. frontUVs?: Vector4;
  69845. backUVs?: Vector4;
  69846. wrap?: boolean;
  69847. topBaseAt?: number;
  69848. bottomBaseAt?: number;
  69849. updatable?: boolean;
  69850. }, scene?: Nullable<Scene>): Mesh;
  69851. /**
  69852. * Creates a tiled box mesh
  69853. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69855. * @param name defines the name of the mesh
  69856. * @param options defines the options used to create the mesh
  69857. * @param scene defines the hosting scene
  69858. * @returns the tiled box mesh
  69859. */
  69860. static CreateTiledBox(name: string, options: {
  69861. pattern?: number;
  69862. size?: number;
  69863. width?: number;
  69864. height?: number;
  69865. depth: number;
  69866. tileSize?: number;
  69867. tileWidth?: number;
  69868. tileHeight?: number;
  69869. faceUV?: Vector4[];
  69870. faceColors?: Color4[];
  69871. alignHorizontal?: number;
  69872. alignVertical?: number;
  69873. sideOrientation?: number;
  69874. updatable?: boolean;
  69875. }, scene?: Nullable<Scene>): Mesh;
  69876. /**
  69877. * Creates a sphere mesh
  69878. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69879. * * 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`)
  69880. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69881. * * 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
  69882. * * 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)
  69883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69884. * * 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
  69885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69886. * @param name defines the name of the mesh
  69887. * @param options defines the options used to create the mesh
  69888. * @param scene defines the hosting scene
  69889. * @returns the sphere mesh
  69890. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69891. */
  69892. static CreateSphere(name: string, options: {
  69893. segments?: number;
  69894. diameter?: number;
  69895. diameterX?: number;
  69896. diameterY?: number;
  69897. diameterZ?: number;
  69898. arc?: number;
  69899. slice?: number;
  69900. sideOrientation?: number;
  69901. frontUVs?: Vector4;
  69902. backUVs?: Vector4;
  69903. updatable?: boolean;
  69904. }, scene?: Nullable<Scene>): Mesh;
  69905. /**
  69906. * Creates a plane polygonal mesh. By default, this is a disc
  69907. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69908. * * 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
  69909. * * 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
  69910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69911. * * 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
  69912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69913. * @param name defines the name of the mesh
  69914. * @param options defines the options used to create the mesh
  69915. * @param scene defines the hosting scene
  69916. * @returns the plane polygonal mesh
  69917. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69918. */
  69919. static CreateDisc(name: string, options: {
  69920. radius?: number;
  69921. tessellation?: number;
  69922. arc?: number;
  69923. updatable?: boolean;
  69924. sideOrientation?: number;
  69925. frontUVs?: Vector4;
  69926. backUVs?: Vector4;
  69927. }, scene?: Nullable<Scene>): Mesh;
  69928. /**
  69929. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69930. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69931. * * 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`)
  69932. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69933. * * 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
  69934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69935. * * 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
  69936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69937. * @param name defines the name of the mesh
  69938. * @param options defines the options used to create the mesh
  69939. * @param scene defines the hosting scene
  69940. * @returns the icosahedron mesh
  69941. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69942. */
  69943. static CreateIcoSphere(name: string, options: {
  69944. radius?: number;
  69945. radiusX?: number;
  69946. radiusY?: number;
  69947. radiusZ?: number;
  69948. flat?: boolean;
  69949. subdivisions?: number;
  69950. sideOrientation?: number;
  69951. frontUVs?: Vector4;
  69952. backUVs?: Vector4;
  69953. updatable?: boolean;
  69954. }, scene?: Nullable<Scene>): Mesh;
  69955. /**
  69956. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69957. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69958. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69959. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69960. * * 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
  69961. * * 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
  69962. * * 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
  69963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69964. * * 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
  69965. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69966. * * 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
  69967. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69968. * * 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
  69969. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69971. * @param name defines the name of the mesh
  69972. * @param options defines the options used to create the mesh
  69973. * @param scene defines the hosting scene
  69974. * @returns the ribbon mesh
  69975. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69976. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69977. */
  69978. static CreateRibbon(name: string, options: {
  69979. pathArray: Vector3[][];
  69980. closeArray?: boolean;
  69981. closePath?: boolean;
  69982. offset?: number;
  69983. updatable?: boolean;
  69984. sideOrientation?: number;
  69985. frontUVs?: Vector4;
  69986. backUVs?: Vector4;
  69987. instance?: Mesh;
  69988. invertUV?: boolean;
  69989. uvs?: Vector2[];
  69990. colors?: Color4[];
  69991. }, scene?: Nullable<Scene>): Mesh;
  69992. /**
  69993. * Creates a cylinder or a cone mesh
  69994. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69995. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69996. * * 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.
  69997. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69998. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69999. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70000. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70001. * * 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).
  70002. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70003. * * 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).
  70004. * * 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
  70005. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70006. * * 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
  70007. * * 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.
  70008. * * If `enclose` is false, a ring surface is one element.
  70009. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70010. * * 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
  70011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70012. * * 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
  70013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70014. * @param name defines the name of the mesh
  70015. * @param options defines the options used to create the mesh
  70016. * @param scene defines the hosting scene
  70017. * @returns the cylinder mesh
  70018. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70019. */
  70020. static CreateCylinder(name: string, options: {
  70021. height?: number;
  70022. diameterTop?: number;
  70023. diameterBottom?: number;
  70024. diameter?: number;
  70025. tessellation?: number;
  70026. subdivisions?: number;
  70027. arc?: number;
  70028. faceColors?: Color4[];
  70029. faceUV?: Vector4[];
  70030. updatable?: boolean;
  70031. hasRings?: boolean;
  70032. enclose?: boolean;
  70033. cap?: number;
  70034. sideOrientation?: number;
  70035. frontUVs?: Vector4;
  70036. backUVs?: Vector4;
  70037. }, scene?: Nullable<Scene>): Mesh;
  70038. /**
  70039. * Creates a torus mesh
  70040. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70041. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70042. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70044. * * 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
  70045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70046. * @param name defines the name of the mesh
  70047. * @param options defines the options used to create the mesh
  70048. * @param scene defines the hosting scene
  70049. * @returns the torus mesh
  70050. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70051. */
  70052. static CreateTorus(name: string, options: {
  70053. diameter?: number;
  70054. thickness?: number;
  70055. tessellation?: number;
  70056. updatable?: boolean;
  70057. sideOrientation?: number;
  70058. frontUVs?: Vector4;
  70059. backUVs?: Vector4;
  70060. }, scene?: Nullable<Scene>): Mesh;
  70061. /**
  70062. * Creates a torus knot mesh
  70063. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70064. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70065. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70066. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70068. * * 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
  70069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70070. * @param name defines the name of the mesh
  70071. * @param options defines the options used to create the mesh
  70072. * @param scene defines the hosting scene
  70073. * @returns the torus knot mesh
  70074. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70075. */
  70076. static CreateTorusKnot(name: string, options: {
  70077. radius?: number;
  70078. tube?: number;
  70079. radialSegments?: number;
  70080. tubularSegments?: number;
  70081. p?: number;
  70082. q?: number;
  70083. updatable?: boolean;
  70084. sideOrientation?: number;
  70085. frontUVs?: Vector4;
  70086. backUVs?: Vector4;
  70087. }, scene?: Nullable<Scene>): Mesh;
  70088. /**
  70089. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70090. * * 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
  70091. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70092. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70093. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70094. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70095. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70096. * * 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
  70097. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70100. * @param name defines the name of the new line system
  70101. * @param options defines the options used to create the line system
  70102. * @param scene defines the hosting scene
  70103. * @returns a new line system mesh
  70104. */
  70105. static CreateLineSystem(name: string, options: {
  70106. lines: Vector3[][];
  70107. updatable?: boolean;
  70108. instance?: Nullable<LinesMesh>;
  70109. colors?: Nullable<Color4[][]>;
  70110. useVertexAlpha?: boolean;
  70111. }, scene: Nullable<Scene>): LinesMesh;
  70112. /**
  70113. * Creates a line mesh
  70114. * 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
  70115. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70116. * * The parameter `points` is an array successive Vector3
  70117. * * 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
  70118. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70119. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70120. * * When updating an instance, remember that only point positions can change, not the number of points
  70121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70123. * @param name defines the name of the new line system
  70124. * @param options defines the options used to create the line system
  70125. * @param scene defines the hosting scene
  70126. * @returns a new line mesh
  70127. */
  70128. static CreateLines(name: string, options: {
  70129. points: Vector3[];
  70130. updatable?: boolean;
  70131. instance?: Nullable<LinesMesh>;
  70132. colors?: Color4[];
  70133. useVertexAlpha?: boolean;
  70134. }, scene?: Nullable<Scene>): LinesMesh;
  70135. /**
  70136. * Creates a dashed line mesh
  70137. * * 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
  70138. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70139. * * The parameter `points` is an array successive Vector3
  70140. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70141. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70142. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70143. * * 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
  70144. * * When updating an instance, remember that only point positions can change, not the number of points
  70145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70146. * @param name defines the name of the mesh
  70147. * @param options defines the options used to create the mesh
  70148. * @param scene defines the hosting scene
  70149. * @returns the dashed line mesh
  70150. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70151. */
  70152. static CreateDashedLines(name: string, options: {
  70153. points: Vector3[];
  70154. dashSize?: number;
  70155. gapSize?: number;
  70156. dashNb?: number;
  70157. updatable?: boolean;
  70158. instance?: LinesMesh;
  70159. }, scene?: Nullable<Scene>): LinesMesh;
  70160. /**
  70161. * 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.
  70162. * * 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.
  70163. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70164. * * 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.
  70165. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70166. * * 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
  70167. * * 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
  70168. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70170. * * 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
  70171. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70173. * @param name defines the name of the mesh
  70174. * @param options defines the options used to create the mesh
  70175. * @param scene defines the hosting scene
  70176. * @returns the extruded shape mesh
  70177. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70178. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70179. */
  70180. static ExtrudeShape(name: string, options: {
  70181. shape: Vector3[];
  70182. path: Vector3[];
  70183. scale?: number;
  70184. rotation?: number;
  70185. cap?: number;
  70186. updatable?: boolean;
  70187. sideOrientation?: number;
  70188. frontUVs?: Vector4;
  70189. backUVs?: Vector4;
  70190. instance?: Mesh;
  70191. invertUV?: boolean;
  70192. }, scene?: Nullable<Scene>): Mesh;
  70193. /**
  70194. * Creates an custom extruded shape mesh.
  70195. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70196. * * 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.
  70197. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70198. * * 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
  70199. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70200. * * 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
  70201. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70202. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70203. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70204. * * 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
  70205. * * 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
  70206. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70208. * * 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
  70209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70211. * @param name defines the name of the mesh
  70212. * @param options defines the options used to create the mesh
  70213. * @param scene defines the hosting scene
  70214. * @returns the custom extruded shape mesh
  70215. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70216. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70218. */
  70219. static ExtrudeShapeCustom(name: string, options: {
  70220. shape: Vector3[];
  70221. path: Vector3[];
  70222. scaleFunction?: any;
  70223. rotationFunction?: any;
  70224. ribbonCloseArray?: boolean;
  70225. ribbonClosePath?: boolean;
  70226. cap?: number;
  70227. updatable?: boolean;
  70228. sideOrientation?: number;
  70229. frontUVs?: Vector4;
  70230. backUVs?: Vector4;
  70231. instance?: Mesh;
  70232. invertUV?: boolean;
  70233. }, scene?: Nullable<Scene>): Mesh;
  70234. /**
  70235. * Creates lathe mesh.
  70236. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70237. * * 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
  70238. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70239. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70240. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70241. * * 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
  70242. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70243. * * 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
  70244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70245. * * 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
  70246. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70248. * @param name defines the name of the mesh
  70249. * @param options defines the options used to create the mesh
  70250. * @param scene defines the hosting scene
  70251. * @returns the lathe mesh
  70252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70253. */
  70254. static CreateLathe(name: string, options: {
  70255. shape: Vector3[];
  70256. radius?: number;
  70257. tessellation?: number;
  70258. clip?: number;
  70259. arc?: number;
  70260. closed?: boolean;
  70261. updatable?: boolean;
  70262. sideOrientation?: number;
  70263. frontUVs?: Vector4;
  70264. backUVs?: Vector4;
  70265. cap?: number;
  70266. invertUV?: boolean;
  70267. }, scene?: Nullable<Scene>): Mesh;
  70268. /**
  70269. * Creates a tiled plane mesh
  70270. * * You can set a limited pattern arrangement with the tiles
  70271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70272. * * 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
  70273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70274. * @param name defines the name of the mesh
  70275. * @param options defines the options used to create the mesh
  70276. * @param scene defines the hosting scene
  70277. * @returns the plane mesh
  70278. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70279. */
  70280. static CreateTiledPlane(name: string, options: {
  70281. pattern?: number;
  70282. tileSize?: number;
  70283. tileWidth?: number;
  70284. tileHeight?: number;
  70285. size?: number;
  70286. width?: number;
  70287. height?: number;
  70288. alignHorizontal?: number;
  70289. alignVertical?: number;
  70290. sideOrientation?: number;
  70291. frontUVs?: Vector4;
  70292. backUVs?: Vector4;
  70293. updatable?: boolean;
  70294. }, scene?: Nullable<Scene>): Mesh;
  70295. /**
  70296. * Creates a plane mesh
  70297. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70298. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70299. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70301. * * 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
  70302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70303. * @param name defines the name of the mesh
  70304. * @param options defines the options used to create the mesh
  70305. * @param scene defines the hosting scene
  70306. * @returns the plane mesh
  70307. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70308. */
  70309. static CreatePlane(name: string, options: {
  70310. size?: number;
  70311. width?: number;
  70312. height?: number;
  70313. sideOrientation?: number;
  70314. frontUVs?: Vector4;
  70315. backUVs?: Vector4;
  70316. updatable?: boolean;
  70317. sourcePlane?: Plane;
  70318. }, scene?: Nullable<Scene>): Mesh;
  70319. /**
  70320. * Creates a ground mesh
  70321. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70322. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70324. * @param name defines the name of the mesh
  70325. * @param options defines the options used to create the mesh
  70326. * @param scene defines the hosting scene
  70327. * @returns the ground mesh
  70328. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70329. */
  70330. static CreateGround(name: string, options: {
  70331. width?: number;
  70332. height?: number;
  70333. subdivisions?: number;
  70334. subdivisionsX?: number;
  70335. subdivisionsY?: number;
  70336. updatable?: boolean;
  70337. }, scene?: Nullable<Scene>): Mesh;
  70338. /**
  70339. * Creates a tiled ground mesh
  70340. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70341. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70342. * * 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
  70343. * * 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
  70344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70345. * @param name defines the name of the mesh
  70346. * @param options defines the options used to create the mesh
  70347. * @param scene defines the hosting scene
  70348. * @returns the tiled ground mesh
  70349. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70350. */
  70351. static CreateTiledGround(name: string, options: {
  70352. xmin: number;
  70353. zmin: number;
  70354. xmax: number;
  70355. zmax: number;
  70356. subdivisions?: {
  70357. w: number;
  70358. h: number;
  70359. };
  70360. precision?: {
  70361. w: number;
  70362. h: number;
  70363. };
  70364. updatable?: boolean;
  70365. }, scene?: Nullable<Scene>): Mesh;
  70366. /**
  70367. * Creates a ground mesh from a height map
  70368. * * The parameter `url` sets the URL of the height map image resource.
  70369. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70370. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70371. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70372. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70373. * * 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.
  70374. * * 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).
  70375. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70377. * @param name defines the name of the mesh
  70378. * @param url defines the url to the height map
  70379. * @param options defines the options used to create the mesh
  70380. * @param scene defines the hosting scene
  70381. * @returns the ground mesh
  70382. * @see https://doc.babylonjs.com/babylon101/height_map
  70383. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70384. */
  70385. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70386. width?: number;
  70387. height?: number;
  70388. subdivisions?: number;
  70389. minHeight?: number;
  70390. maxHeight?: number;
  70391. colorFilter?: Color3;
  70392. alphaFilter?: number;
  70393. updatable?: boolean;
  70394. onReady?: (mesh: GroundMesh) => void;
  70395. }, scene?: Nullable<Scene>): GroundMesh;
  70396. /**
  70397. * Creates a polygon mesh
  70398. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70399. * * 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
  70400. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  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. * * 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)
  70403. * * Remember you can only change the shape positions, not their number when updating a polygon
  70404. * @param name defines the name of the mesh
  70405. * @param options defines the options used to create the mesh
  70406. * @param scene defines the hosting scene
  70407. * @param earcutInjection can be used to inject your own earcut reference
  70408. * @returns the polygon mesh
  70409. */
  70410. static CreatePolygon(name: string, options: {
  70411. shape: Vector3[];
  70412. holes?: Vector3[][];
  70413. depth?: number;
  70414. faceUV?: Vector4[];
  70415. faceColors?: Color4[];
  70416. updatable?: boolean;
  70417. sideOrientation?: number;
  70418. frontUVs?: Vector4;
  70419. backUVs?: Vector4;
  70420. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70421. /**
  70422. * Creates an extruded polygon mesh, with depth in the Y direction.
  70423. * * 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)
  70424. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70425. * @param name defines the name of the mesh
  70426. * @param options defines the options used to create the mesh
  70427. * @param scene defines the hosting scene
  70428. * @param earcutInjection can be used to inject your own earcut reference
  70429. * @returns the polygon mesh
  70430. */
  70431. static ExtrudePolygon(name: string, options: {
  70432. shape: Vector3[];
  70433. holes?: Vector3[][];
  70434. depth?: number;
  70435. faceUV?: Vector4[];
  70436. faceColors?: Color4[];
  70437. updatable?: boolean;
  70438. sideOrientation?: number;
  70439. frontUVs?: Vector4;
  70440. backUVs?: Vector4;
  70441. wrap?: boolean;
  70442. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70443. /**
  70444. * Creates a tube mesh.
  70445. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70446. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70447. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70448. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70449. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70450. * * 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)
  70451. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70452. * * 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
  70453. * * 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
  70454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70455. * * 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
  70456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70458. * @param name defines the name of the mesh
  70459. * @param options defines the options used to create the mesh
  70460. * @param scene defines the hosting scene
  70461. * @returns the tube mesh
  70462. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70463. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70464. */
  70465. static CreateTube(name: string, options: {
  70466. path: Vector3[];
  70467. radius?: number;
  70468. tessellation?: number;
  70469. radiusFunction?: {
  70470. (i: number, distance: number): number;
  70471. };
  70472. cap?: number;
  70473. arc?: number;
  70474. updatable?: boolean;
  70475. sideOrientation?: number;
  70476. frontUVs?: Vector4;
  70477. backUVs?: Vector4;
  70478. instance?: Mesh;
  70479. invertUV?: boolean;
  70480. }, scene?: Nullable<Scene>): Mesh;
  70481. /**
  70482. * Creates a polyhedron mesh
  70483. * * 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
  70484. * * The parameter `size` (positive float, default 1) sets the polygon size
  70485. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70486. * * 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`
  70487. * * 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
  70488. * * 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)`)
  70489. * * 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
  70490. * * 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
  70491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70492. * * 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
  70493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70494. * @param name defines the name of the mesh
  70495. * @param options defines the options used to create the mesh
  70496. * @param scene defines the hosting scene
  70497. * @returns the polyhedron mesh
  70498. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70499. */
  70500. static CreatePolyhedron(name: string, options: {
  70501. type?: number;
  70502. size?: number;
  70503. sizeX?: number;
  70504. sizeY?: number;
  70505. sizeZ?: number;
  70506. custom?: any;
  70507. faceUV?: Vector4[];
  70508. faceColors?: Color4[];
  70509. flat?: boolean;
  70510. updatable?: boolean;
  70511. sideOrientation?: number;
  70512. frontUVs?: Vector4;
  70513. backUVs?: Vector4;
  70514. }, scene?: Nullable<Scene>): Mesh;
  70515. /**
  70516. * Creates a decal mesh.
  70517. * 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
  70518. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70519. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70520. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70521. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70522. * @param name defines the name of the mesh
  70523. * @param sourceMesh defines the mesh where the decal must be applied
  70524. * @param options defines the options used to create the mesh
  70525. * @param scene defines the hosting scene
  70526. * @returns the decal mesh
  70527. * @see https://doc.babylonjs.com/how_to/decals
  70528. */
  70529. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70530. position?: Vector3;
  70531. normal?: Vector3;
  70532. size?: Vector3;
  70533. angle?: number;
  70534. }): Mesh;
  70535. /**
  70536. * Creates a Capsule Mesh
  70537. * @param name defines the name of the mesh.
  70538. * @param options the constructors options used to shape the mesh.
  70539. * @param scene defines the scene the mesh is scoped to.
  70540. * @returns the capsule mesh
  70541. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70542. */
  70543. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70544. }
  70545. }
  70546. declare module BABYLON {
  70547. /**
  70548. * A simplifier interface for future simplification implementations
  70549. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70550. */
  70551. export interface ISimplifier {
  70552. /**
  70553. * Simplification of a given mesh according to the given settings.
  70554. * Since this requires computation, it is assumed that the function runs async.
  70555. * @param settings The settings of the simplification, including quality and distance
  70556. * @param successCallback A callback that will be called after the mesh was simplified.
  70557. * @param errorCallback in case of an error, this callback will be called. optional.
  70558. */
  70559. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70560. }
  70561. /**
  70562. * Expected simplification settings.
  70563. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70564. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70565. */
  70566. export interface ISimplificationSettings {
  70567. /**
  70568. * Gets or sets the expected quality
  70569. */
  70570. quality: number;
  70571. /**
  70572. * Gets or sets the distance when this optimized version should be used
  70573. */
  70574. distance: number;
  70575. /**
  70576. * Gets an already optimized mesh
  70577. */
  70578. optimizeMesh?: boolean;
  70579. }
  70580. /**
  70581. * Class used to specify simplification options
  70582. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70583. */
  70584. export class SimplificationSettings implements ISimplificationSettings {
  70585. /** expected quality */
  70586. quality: number;
  70587. /** distance when this optimized version should be used */
  70588. distance: number;
  70589. /** already optimized mesh */
  70590. optimizeMesh?: boolean | undefined;
  70591. /**
  70592. * Creates a SimplificationSettings
  70593. * @param quality expected quality
  70594. * @param distance distance when this optimized version should be used
  70595. * @param optimizeMesh already optimized mesh
  70596. */
  70597. constructor(
  70598. /** expected quality */
  70599. quality: number,
  70600. /** distance when this optimized version should be used */
  70601. distance: number,
  70602. /** already optimized mesh */
  70603. optimizeMesh?: boolean | undefined);
  70604. }
  70605. /**
  70606. * Interface used to define a simplification task
  70607. */
  70608. export interface ISimplificationTask {
  70609. /**
  70610. * Array of settings
  70611. */
  70612. settings: Array<ISimplificationSettings>;
  70613. /**
  70614. * Simplification type
  70615. */
  70616. simplificationType: SimplificationType;
  70617. /**
  70618. * Mesh to simplify
  70619. */
  70620. mesh: Mesh;
  70621. /**
  70622. * Callback called on success
  70623. */
  70624. successCallback?: () => void;
  70625. /**
  70626. * Defines if parallel processing can be used
  70627. */
  70628. parallelProcessing: boolean;
  70629. }
  70630. /**
  70631. * Queue used to order the simplification tasks
  70632. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70633. */
  70634. export class SimplificationQueue {
  70635. private _simplificationArray;
  70636. /**
  70637. * Gets a boolean indicating that the process is still running
  70638. */
  70639. running: boolean;
  70640. /**
  70641. * Creates a new queue
  70642. */
  70643. constructor();
  70644. /**
  70645. * Adds a new simplification task
  70646. * @param task defines a task to add
  70647. */
  70648. addTask(task: ISimplificationTask): void;
  70649. /**
  70650. * Execute next task
  70651. */
  70652. executeNext(): void;
  70653. /**
  70654. * Execute a simplification task
  70655. * @param task defines the task to run
  70656. */
  70657. runSimplification(task: ISimplificationTask): void;
  70658. private getSimplifier;
  70659. }
  70660. /**
  70661. * The implemented types of simplification
  70662. * At the moment only Quadratic Error Decimation is implemented
  70663. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70664. */
  70665. export enum SimplificationType {
  70666. /** Quadratic error decimation */
  70667. QUADRATIC = 0
  70668. }
  70669. /**
  70670. * An implementation of the Quadratic Error simplification algorithm.
  70671. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70672. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70673. * @author RaananW
  70674. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70675. */
  70676. export class QuadraticErrorSimplification implements ISimplifier {
  70677. private _mesh;
  70678. private triangles;
  70679. private vertices;
  70680. private references;
  70681. private _reconstructedMesh;
  70682. /** Gets or sets the number pf sync interations */
  70683. syncIterations: number;
  70684. /** Gets or sets the aggressiveness of the simplifier */
  70685. aggressiveness: number;
  70686. /** Gets or sets the number of allowed iterations for decimation */
  70687. decimationIterations: number;
  70688. /** Gets or sets the espilon to use for bounding box computation */
  70689. boundingBoxEpsilon: number;
  70690. /**
  70691. * Creates a new QuadraticErrorSimplification
  70692. * @param _mesh defines the target mesh
  70693. */
  70694. constructor(_mesh: Mesh);
  70695. /**
  70696. * Simplification of a given mesh according to the given settings.
  70697. * Since this requires computation, it is assumed that the function runs async.
  70698. * @param settings The settings of the simplification, including quality and distance
  70699. * @param successCallback A callback that will be called after the mesh was simplified.
  70700. */
  70701. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70702. private runDecimation;
  70703. private initWithMesh;
  70704. private init;
  70705. private reconstructMesh;
  70706. private initDecimatedMesh;
  70707. private isFlipped;
  70708. private updateTriangles;
  70709. private identifyBorder;
  70710. private updateMesh;
  70711. private vertexError;
  70712. private calculateError;
  70713. }
  70714. }
  70715. declare module BABYLON {
  70716. interface Scene {
  70717. /** @hidden (Backing field) */
  70718. _simplificationQueue: SimplificationQueue;
  70719. /**
  70720. * Gets or sets the simplification queue attached to the scene
  70721. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70722. */
  70723. simplificationQueue: SimplificationQueue;
  70724. }
  70725. interface Mesh {
  70726. /**
  70727. * Simplify the mesh according to the given array of settings.
  70728. * Function will return immediately and will simplify async
  70729. * @param settings a collection of simplification settings
  70730. * @param parallelProcessing should all levels calculate parallel or one after the other
  70731. * @param simplificationType the type of simplification to run
  70732. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70733. * @returns the current mesh
  70734. */
  70735. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70736. }
  70737. /**
  70738. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70739. * created in a scene
  70740. */
  70741. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70742. /**
  70743. * The component name helpfull to identify the component in the list of scene components.
  70744. */
  70745. readonly name: string;
  70746. /**
  70747. * The scene the component belongs to.
  70748. */
  70749. scene: Scene;
  70750. /**
  70751. * Creates a new instance of the component for the given scene
  70752. * @param scene Defines the scene to register the component in
  70753. */
  70754. constructor(scene: Scene);
  70755. /**
  70756. * Registers the component in a given scene
  70757. */
  70758. register(): void;
  70759. /**
  70760. * Rebuilds the elements related to this component in case of
  70761. * context lost for instance.
  70762. */
  70763. rebuild(): void;
  70764. /**
  70765. * Disposes the component and the associated ressources
  70766. */
  70767. dispose(): void;
  70768. private _beforeCameraUpdate;
  70769. }
  70770. }
  70771. declare module BABYLON {
  70772. interface Mesh {
  70773. /**
  70774. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70775. */
  70776. thinInstanceEnablePicking: boolean;
  70777. /**
  70778. * Creates a new thin instance
  70779. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70780. * @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
  70781. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70782. */
  70783. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70784. /**
  70785. * Adds the transformation (matrix) of the current mesh as a thin instance
  70786. * @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
  70787. * @returns the thin instance index number
  70788. */
  70789. thinInstanceAddSelf(refresh: boolean): number;
  70790. /**
  70791. * Registers a custom attribute to be used with thin instances
  70792. * @param kind name of the attribute
  70793. * @param stride size in floats of the attribute
  70794. */
  70795. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70796. /**
  70797. * Sets the matrix of a thin instance
  70798. * @param index index of the thin instance
  70799. * @param matrix matrix to set
  70800. * @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
  70801. */
  70802. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70803. /**
  70804. * Sets the value of a custom attribute for a thin instance
  70805. * @param kind name of the attribute
  70806. * @param index index of the thin instance
  70807. * @param value value to set
  70808. * @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
  70809. */
  70810. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70811. /**
  70812. * 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.
  70813. */
  70814. thinInstanceCount: number;
  70815. /**
  70816. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70817. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70818. * @param buffer buffer to set
  70819. * @param stride size in floats of each value of the buffer
  70820. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70821. */
  70822. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70823. /**
  70824. * Gets the list of world matrices
  70825. * @return an array containing all the world matrices from the thin instances
  70826. */
  70827. thinInstanceGetWorldMatrices(): Matrix[];
  70828. /**
  70829. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70830. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70831. */
  70832. thinInstanceBufferUpdated(kind: string): void;
  70833. /**
  70834. * Applies a partial update to a buffer directly on the GPU
  70835. * 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
  70836. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70837. * @param data the data to set in the GPU buffer
  70838. * @param offset the offset in the GPU buffer where to update the data
  70839. */
  70840. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70841. /**
  70842. * Refreshes the bounding info, taking into account all the thin instances defined
  70843. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70844. */
  70845. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70846. /** @hidden */
  70847. _thinInstanceInitializeUserStorage(): void;
  70848. /** @hidden */
  70849. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70850. /** @hidden */
  70851. _userThinInstanceBuffersStorage: {
  70852. data: {
  70853. [key: string]: Float32Array;
  70854. };
  70855. sizes: {
  70856. [key: string]: number;
  70857. };
  70858. vertexBuffers: {
  70859. [key: string]: Nullable<VertexBuffer>;
  70860. };
  70861. strides: {
  70862. [key: string]: number;
  70863. };
  70864. };
  70865. }
  70866. }
  70867. declare module BABYLON {
  70868. /**
  70869. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70870. */
  70871. export interface INavigationEnginePlugin {
  70872. /**
  70873. * plugin name
  70874. */
  70875. name: string;
  70876. /**
  70877. * Creates a navigation mesh
  70878. * @param meshes array of all the geometry used to compute the navigatio mesh
  70879. * @param parameters bunch of parameters used to filter geometry
  70880. */
  70881. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70882. /**
  70883. * Create a navigation mesh debug mesh
  70884. * @param scene is where the mesh will be added
  70885. * @returns debug display mesh
  70886. */
  70887. createDebugNavMesh(scene: Scene): Mesh;
  70888. /**
  70889. * Get a navigation mesh constrained position, closest to the parameter position
  70890. * @param position world position
  70891. * @returns the closest point to position constrained by the navigation mesh
  70892. */
  70893. getClosestPoint(position: Vector3): Vector3;
  70894. /**
  70895. * Get a navigation mesh constrained position, closest to the parameter position
  70896. * @param position world position
  70897. * @param result output the closest point to position constrained by the navigation mesh
  70898. */
  70899. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70900. /**
  70901. * Get a navigation mesh constrained position, within a particular radius
  70902. * @param position world position
  70903. * @param maxRadius the maximum distance to the constrained world position
  70904. * @returns the closest point to position constrained by the navigation mesh
  70905. */
  70906. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70907. /**
  70908. * Get a navigation mesh constrained position, within a particular radius
  70909. * @param position world position
  70910. * @param maxRadius the maximum distance to the constrained world position
  70911. * @param result output the closest point to position constrained by the navigation mesh
  70912. */
  70913. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70914. /**
  70915. * Compute the final position from a segment made of destination-position
  70916. * @param position world position
  70917. * @param destination world position
  70918. * @returns the resulting point along the navmesh
  70919. */
  70920. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70921. /**
  70922. * Compute the final position from a segment made of destination-position
  70923. * @param position world position
  70924. * @param destination world position
  70925. * @param result output the resulting point along the navmesh
  70926. */
  70927. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70928. /**
  70929. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70930. * @param start world position
  70931. * @param end world position
  70932. * @returns array containing world position composing the path
  70933. */
  70934. computePath(start: Vector3, end: Vector3): Vector3[];
  70935. /**
  70936. * If this plugin is supported
  70937. * @returns true if plugin is supported
  70938. */
  70939. isSupported(): boolean;
  70940. /**
  70941. * Create a new Crowd so you can add agents
  70942. * @param maxAgents the maximum agent count in the crowd
  70943. * @param maxAgentRadius the maximum radius an agent can have
  70944. * @param scene to attach the crowd to
  70945. * @returns the crowd you can add agents to
  70946. */
  70947. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70948. /**
  70949. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70950. * The queries will try to find a solution within those bounds
  70951. * default is (1,1,1)
  70952. * @param extent x,y,z value that define the extent around the queries point of reference
  70953. */
  70954. setDefaultQueryExtent(extent: Vector3): void;
  70955. /**
  70956. * Get the Bounding box extent specified by setDefaultQueryExtent
  70957. * @returns the box extent values
  70958. */
  70959. getDefaultQueryExtent(): Vector3;
  70960. /**
  70961. * build the navmesh from a previously saved state using getNavmeshData
  70962. * @param data the Uint8Array returned by getNavmeshData
  70963. */
  70964. buildFromNavmeshData(data: Uint8Array): void;
  70965. /**
  70966. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70967. * @returns data the Uint8Array that can be saved and reused
  70968. */
  70969. getNavmeshData(): Uint8Array;
  70970. /**
  70971. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70972. * @param result output the box extent values
  70973. */
  70974. getDefaultQueryExtentToRef(result: Vector3): void;
  70975. /**
  70976. * Set the time step of the navigation tick update.
  70977. * Default is 1/60.
  70978. * A value of 0 will disable fixed time update
  70979. * @param newTimeStep the new timestep to apply to this world.
  70980. */
  70981. setTimeStep(newTimeStep: number): void;
  70982. /**
  70983. * Get the time step of the navigation tick update.
  70984. * @returns the current time step
  70985. */
  70986. getTimeStep(): number;
  70987. /**
  70988. * If delta time in navigation tick update is greater than the time step
  70989. * a number of sub iterations are done. If more iterations are need to reach deltatime
  70990. * they will be discarded.
  70991. * A value of 0 will set to no maximum and update will use as many substeps as needed
  70992. * @param newStepCount the maximum number of iterations
  70993. */
  70994. setMaximumSubStepCount(newStepCount: number): void;
  70995. /**
  70996. * Get the maximum number of iterations per navigation tick update
  70997. * @returns the maximum number of iterations
  70998. */
  70999. getMaximumSubStepCount(): number;
  71000. /**
  71001. * Release all resources
  71002. */
  71003. dispose(): void;
  71004. }
  71005. /**
  71006. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71007. */
  71008. export interface ICrowd {
  71009. /**
  71010. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71011. * You can attach anything to that node. The node position is updated in the scene update tick.
  71012. * @param pos world position that will be constrained by the navigation mesh
  71013. * @param parameters agent parameters
  71014. * @param transform hooked to the agent that will be update by the scene
  71015. * @returns agent index
  71016. */
  71017. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71018. /**
  71019. * Returns the agent position in world space
  71020. * @param index agent index returned by addAgent
  71021. * @returns world space position
  71022. */
  71023. getAgentPosition(index: number): Vector3;
  71024. /**
  71025. * Gets the agent position result in world space
  71026. * @param index agent index returned by addAgent
  71027. * @param result output world space position
  71028. */
  71029. getAgentPositionToRef(index: number, result: Vector3): void;
  71030. /**
  71031. * Gets the agent velocity in world space
  71032. * @param index agent index returned by addAgent
  71033. * @returns world space velocity
  71034. */
  71035. getAgentVelocity(index: number): Vector3;
  71036. /**
  71037. * Gets the agent velocity result in world space
  71038. * @param index agent index returned by addAgent
  71039. * @param result output world space velocity
  71040. */
  71041. getAgentVelocityToRef(index: number, result: Vector3): void;
  71042. /**
  71043. * Gets the agent next target point on the path
  71044. * @param index agent index returned by addAgent
  71045. * @returns world space position
  71046. */
  71047. getAgentNextTargetPath(index: number): Vector3;
  71048. /**
  71049. * Gets the agent state
  71050. * @param index agent index returned by addAgent
  71051. * @returns agent state
  71052. */
  71053. getAgentState(index: number): number;
  71054. /**
  71055. * returns true if the agent in over an off mesh link connection
  71056. * @param index agent index returned by addAgent
  71057. * @returns true if over an off mesh link connection
  71058. */
  71059. overOffmeshConnection(index: number): boolean;
  71060. /**
  71061. * Gets the agent next target point on the path
  71062. * @param index agent index returned by addAgent
  71063. * @param result output world space position
  71064. */
  71065. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71066. /**
  71067. * remove a particular agent previously created
  71068. * @param index agent index returned by addAgent
  71069. */
  71070. removeAgent(index: number): void;
  71071. /**
  71072. * get the list of all agents attached to this crowd
  71073. * @returns list of agent indices
  71074. */
  71075. getAgents(): number[];
  71076. /**
  71077. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71078. * @param deltaTime in seconds
  71079. */
  71080. update(deltaTime: number): void;
  71081. /**
  71082. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71083. * @param index agent index returned by addAgent
  71084. * @param destination targeted world position
  71085. */
  71086. agentGoto(index: number, destination: Vector3): void;
  71087. /**
  71088. * Teleport the agent to a new position
  71089. * @param index agent index returned by addAgent
  71090. * @param destination targeted world position
  71091. */
  71092. agentTeleport(index: number, destination: Vector3): void;
  71093. /**
  71094. * Update agent parameters
  71095. * @param index agent index returned by addAgent
  71096. * @param parameters agent parameters
  71097. */
  71098. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71099. /**
  71100. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71101. * The queries will try to find a solution within those bounds
  71102. * default is (1,1,1)
  71103. * @param extent x,y,z value that define the extent around the queries point of reference
  71104. */
  71105. setDefaultQueryExtent(extent: Vector3): void;
  71106. /**
  71107. * Get the Bounding box extent specified by setDefaultQueryExtent
  71108. * @returns the box extent values
  71109. */
  71110. getDefaultQueryExtent(): Vector3;
  71111. /**
  71112. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71113. * @param result output the box extent values
  71114. */
  71115. getDefaultQueryExtentToRef(result: Vector3): void;
  71116. /**
  71117. * Release all resources
  71118. */
  71119. dispose(): void;
  71120. }
  71121. /**
  71122. * Configures an agent
  71123. */
  71124. export interface IAgentParameters {
  71125. /**
  71126. * Agent radius. [Limit: >= 0]
  71127. */
  71128. radius: number;
  71129. /**
  71130. * Agent height. [Limit: > 0]
  71131. */
  71132. height: number;
  71133. /**
  71134. * Maximum allowed acceleration. [Limit: >= 0]
  71135. */
  71136. maxAcceleration: number;
  71137. /**
  71138. * Maximum allowed speed. [Limit: >= 0]
  71139. */
  71140. maxSpeed: number;
  71141. /**
  71142. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71143. */
  71144. collisionQueryRange: number;
  71145. /**
  71146. * The path visibility optimization range. [Limit: > 0]
  71147. */
  71148. pathOptimizationRange: number;
  71149. /**
  71150. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71151. */
  71152. separationWeight: number;
  71153. }
  71154. /**
  71155. * Configures the navigation mesh creation
  71156. */
  71157. export interface INavMeshParameters {
  71158. /**
  71159. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71160. */
  71161. cs: number;
  71162. /**
  71163. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71164. */
  71165. ch: number;
  71166. /**
  71167. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71168. */
  71169. walkableSlopeAngle: number;
  71170. /**
  71171. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71172. * be considered walkable. [Limit: >= 3] [Units: vx]
  71173. */
  71174. walkableHeight: number;
  71175. /**
  71176. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71177. */
  71178. walkableClimb: number;
  71179. /**
  71180. * The distance to erode/shrink the walkable area of the heightfield away from
  71181. * obstructions. [Limit: >=0] [Units: vx]
  71182. */
  71183. walkableRadius: number;
  71184. /**
  71185. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71186. */
  71187. maxEdgeLen: number;
  71188. /**
  71189. * The maximum distance a simplfied contour's border edges should deviate
  71190. * the original raw contour. [Limit: >=0] [Units: vx]
  71191. */
  71192. maxSimplificationError: number;
  71193. /**
  71194. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71195. */
  71196. minRegionArea: number;
  71197. /**
  71198. * Any regions with a span count smaller than this value will, if possible,
  71199. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71200. */
  71201. mergeRegionArea: number;
  71202. /**
  71203. * The maximum number of vertices allowed for polygons generated during the
  71204. * contour to polygon conversion process. [Limit: >= 3]
  71205. */
  71206. maxVertsPerPoly: number;
  71207. /**
  71208. * Sets the sampling distance to use when generating the detail mesh.
  71209. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71210. */
  71211. detailSampleDist: number;
  71212. /**
  71213. * The maximum distance the detail mesh surface should deviate from heightfield
  71214. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71215. */
  71216. detailSampleMaxError: number;
  71217. }
  71218. }
  71219. declare module BABYLON {
  71220. /**
  71221. * RecastJS navigation plugin
  71222. */
  71223. export class RecastJSPlugin implements INavigationEnginePlugin {
  71224. /**
  71225. * Reference to the Recast library
  71226. */
  71227. bjsRECAST: any;
  71228. /**
  71229. * plugin name
  71230. */
  71231. name: string;
  71232. /**
  71233. * the first navmesh created. We might extend this to support multiple navmeshes
  71234. */
  71235. navMesh: any;
  71236. private _maximumSubStepCount;
  71237. private _timeStep;
  71238. /**
  71239. * Initializes the recastJS plugin
  71240. * @param recastInjection can be used to inject your own recast reference
  71241. */
  71242. constructor(recastInjection?: any);
  71243. /**
  71244. * Set the time step of the navigation tick update.
  71245. * Default is 1/60.
  71246. * A value of 0 will disable fixed time update
  71247. * @param newTimeStep the new timestep to apply to this world.
  71248. */
  71249. setTimeStep(newTimeStep?: number): void;
  71250. /**
  71251. * Get the time step of the navigation tick update.
  71252. * @returns the current time step
  71253. */
  71254. getTimeStep(): number;
  71255. /**
  71256. * If delta time in navigation tick update is greater than the time step
  71257. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71258. * they will be discarded.
  71259. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71260. * @param newStepCount the maximum number of iterations
  71261. */
  71262. setMaximumSubStepCount(newStepCount?: number): void;
  71263. /**
  71264. * Get the maximum number of iterations per navigation tick update
  71265. * @returns the maximum number of iterations
  71266. */
  71267. getMaximumSubStepCount(): number;
  71268. /**
  71269. * Creates a navigation mesh
  71270. * @param meshes array of all the geometry used to compute the navigatio mesh
  71271. * @param parameters bunch of parameters used to filter geometry
  71272. */
  71273. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71274. /**
  71275. * Create a navigation mesh debug mesh
  71276. * @param scene is where the mesh will be added
  71277. * @returns debug display mesh
  71278. */
  71279. createDebugNavMesh(scene: Scene): Mesh;
  71280. /**
  71281. * Get a navigation mesh constrained position, closest to the parameter position
  71282. * @param position world position
  71283. * @returns the closest point to position constrained by the navigation mesh
  71284. */
  71285. getClosestPoint(position: Vector3): Vector3;
  71286. /**
  71287. * Get a navigation mesh constrained position, closest to the parameter position
  71288. * @param position world position
  71289. * @param result output the closest point to position constrained by the navigation mesh
  71290. */
  71291. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71292. /**
  71293. * Get a navigation mesh constrained position, within a particular radius
  71294. * @param position world position
  71295. * @param maxRadius the maximum distance to the constrained world position
  71296. * @returns the closest point to position constrained by the navigation mesh
  71297. */
  71298. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71299. /**
  71300. * Get a navigation mesh constrained position, within a particular radius
  71301. * @param position world position
  71302. * @param maxRadius the maximum distance to the constrained world position
  71303. * @param result output the closest point to position constrained by the navigation mesh
  71304. */
  71305. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71306. /**
  71307. * Compute the final position from a segment made of destination-position
  71308. * @param position world position
  71309. * @param destination world position
  71310. * @returns the resulting point along the navmesh
  71311. */
  71312. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71313. /**
  71314. * Compute the final position from a segment made of destination-position
  71315. * @param position world position
  71316. * @param destination world position
  71317. * @param result output the resulting point along the navmesh
  71318. */
  71319. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71320. /**
  71321. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71322. * @param start world position
  71323. * @param end world position
  71324. * @returns array containing world position composing the path
  71325. */
  71326. computePath(start: Vector3, end: Vector3): Vector3[];
  71327. /**
  71328. * Create a new Crowd so you can add agents
  71329. * @param maxAgents the maximum agent count in the crowd
  71330. * @param maxAgentRadius the maximum radius an agent can have
  71331. * @param scene to attach the crowd to
  71332. * @returns the crowd you can add agents to
  71333. */
  71334. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71335. /**
  71336. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71337. * The queries will try to find a solution within those bounds
  71338. * default is (1,1,1)
  71339. * @param extent x,y,z value that define the extent around the queries point of reference
  71340. */
  71341. setDefaultQueryExtent(extent: Vector3): void;
  71342. /**
  71343. * Get the Bounding box extent specified by setDefaultQueryExtent
  71344. * @returns the box extent values
  71345. */
  71346. getDefaultQueryExtent(): Vector3;
  71347. /**
  71348. * build the navmesh from a previously saved state using getNavmeshData
  71349. * @param data the Uint8Array returned by getNavmeshData
  71350. */
  71351. buildFromNavmeshData(data: Uint8Array): void;
  71352. /**
  71353. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71354. * @returns data the Uint8Array that can be saved and reused
  71355. */
  71356. getNavmeshData(): Uint8Array;
  71357. /**
  71358. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71359. * @param result output the box extent values
  71360. */
  71361. getDefaultQueryExtentToRef(result: Vector3): void;
  71362. /**
  71363. * Disposes
  71364. */
  71365. dispose(): void;
  71366. /**
  71367. * If this plugin is supported
  71368. * @returns true if plugin is supported
  71369. */
  71370. isSupported(): boolean;
  71371. }
  71372. /**
  71373. * Recast detour crowd implementation
  71374. */
  71375. export class RecastJSCrowd implements ICrowd {
  71376. /**
  71377. * Recast/detour plugin
  71378. */
  71379. bjsRECASTPlugin: RecastJSPlugin;
  71380. /**
  71381. * Link to the detour crowd
  71382. */
  71383. recastCrowd: any;
  71384. /**
  71385. * One transform per agent
  71386. */
  71387. transforms: TransformNode[];
  71388. /**
  71389. * All agents created
  71390. */
  71391. agents: number[];
  71392. /**
  71393. * Link to the scene is kept to unregister the crowd from the scene
  71394. */
  71395. private _scene;
  71396. /**
  71397. * Observer for crowd updates
  71398. */
  71399. private _onBeforeAnimationsObserver;
  71400. /**
  71401. * Constructor
  71402. * @param plugin recastJS plugin
  71403. * @param maxAgents the maximum agent count in the crowd
  71404. * @param maxAgentRadius the maximum radius an agent can have
  71405. * @param scene to attach the crowd to
  71406. * @returns the crowd you can add agents to
  71407. */
  71408. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71409. /**
  71410. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71411. * You can attach anything to that node. The node position is updated in the scene update tick.
  71412. * @param pos world position that will be constrained by the navigation mesh
  71413. * @param parameters agent parameters
  71414. * @param transform hooked to the agent that will be update by the scene
  71415. * @returns agent index
  71416. */
  71417. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71418. /**
  71419. * Returns the agent position in world space
  71420. * @param index agent index returned by addAgent
  71421. * @returns world space position
  71422. */
  71423. getAgentPosition(index: number): Vector3;
  71424. /**
  71425. * Returns the agent position result in world space
  71426. * @param index agent index returned by addAgent
  71427. * @param result output world space position
  71428. */
  71429. getAgentPositionToRef(index: number, result: Vector3): void;
  71430. /**
  71431. * Returns the agent velocity in world space
  71432. * @param index agent index returned by addAgent
  71433. * @returns world space velocity
  71434. */
  71435. getAgentVelocity(index: number): Vector3;
  71436. /**
  71437. * Returns the agent velocity result in world space
  71438. * @param index agent index returned by addAgent
  71439. * @param result output world space velocity
  71440. */
  71441. getAgentVelocityToRef(index: number, result: Vector3): void;
  71442. /**
  71443. * Returns the agent next target point on the path
  71444. * @param index agent index returned by addAgent
  71445. * @returns world space position
  71446. */
  71447. getAgentNextTargetPath(index: number): Vector3;
  71448. /**
  71449. * Returns the agent next target point on the path
  71450. * @param index agent index returned by addAgent
  71451. * @param result output world space position
  71452. */
  71453. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71454. /**
  71455. * Gets the agent state
  71456. * @param index agent index returned by addAgent
  71457. * @returns agent state
  71458. */
  71459. getAgentState(index: number): number;
  71460. /**
  71461. * returns true if the agent in over an off mesh link connection
  71462. * @param index agent index returned by addAgent
  71463. * @returns true if over an off mesh link connection
  71464. */
  71465. overOffmeshConnection(index: number): boolean;
  71466. /**
  71467. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71468. * @param index agent index returned by addAgent
  71469. * @param destination targeted world position
  71470. */
  71471. agentGoto(index: number, destination: Vector3): void;
  71472. /**
  71473. * Teleport the agent to a new position
  71474. * @param index agent index returned by addAgent
  71475. * @param destination targeted world position
  71476. */
  71477. agentTeleport(index: number, destination: Vector3): void;
  71478. /**
  71479. * Update agent parameters
  71480. * @param index agent index returned by addAgent
  71481. * @param parameters agent parameters
  71482. */
  71483. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71484. /**
  71485. * remove a particular agent previously created
  71486. * @param index agent index returned by addAgent
  71487. */
  71488. removeAgent(index: number): void;
  71489. /**
  71490. * get the list of all agents attached to this crowd
  71491. * @returns list of agent indices
  71492. */
  71493. getAgents(): number[];
  71494. /**
  71495. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71496. * @param deltaTime in seconds
  71497. */
  71498. update(deltaTime: number): void;
  71499. /**
  71500. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71501. * The queries will try to find a solution within those bounds
  71502. * default is (1,1,1)
  71503. * @param extent x,y,z value that define the extent around the queries point of reference
  71504. */
  71505. setDefaultQueryExtent(extent: Vector3): void;
  71506. /**
  71507. * Get the Bounding box extent specified by setDefaultQueryExtent
  71508. * @returns the box extent values
  71509. */
  71510. getDefaultQueryExtent(): Vector3;
  71511. /**
  71512. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71513. * @param result output the box extent values
  71514. */
  71515. getDefaultQueryExtentToRef(result: Vector3): void;
  71516. /**
  71517. * Release all resources
  71518. */
  71519. dispose(): void;
  71520. }
  71521. }
  71522. declare module BABYLON {
  71523. /**
  71524. * Class used to enable access to IndexedDB
  71525. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71526. */
  71527. export class Database implements IOfflineProvider {
  71528. private _callbackManifestChecked;
  71529. private _currentSceneUrl;
  71530. private _db;
  71531. private _enableSceneOffline;
  71532. private _enableTexturesOffline;
  71533. private _manifestVersionFound;
  71534. private _mustUpdateRessources;
  71535. private _hasReachedQuota;
  71536. private _isSupported;
  71537. private _idbFactory;
  71538. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71539. private static IsUASupportingBlobStorage;
  71540. /**
  71541. * Gets a boolean indicating if Database storate is enabled (off by default)
  71542. */
  71543. static IDBStorageEnabled: boolean;
  71544. /**
  71545. * Gets a boolean indicating if scene must be saved in the database
  71546. */
  71547. get enableSceneOffline(): boolean;
  71548. /**
  71549. * Gets a boolean indicating if textures must be saved in the database
  71550. */
  71551. get enableTexturesOffline(): boolean;
  71552. /**
  71553. * Creates a new Database
  71554. * @param urlToScene defines the url to load the scene
  71555. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71556. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71557. */
  71558. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71559. private static _ParseURL;
  71560. private static _ReturnFullUrlLocation;
  71561. private _checkManifestFile;
  71562. /**
  71563. * Open the database and make it available
  71564. * @param successCallback defines the callback to call on success
  71565. * @param errorCallback defines the callback to call on error
  71566. */
  71567. open(successCallback: () => void, errorCallback: () => void): void;
  71568. /**
  71569. * Loads an image from the database
  71570. * @param url defines the url to load from
  71571. * @param image defines the target DOM image
  71572. */
  71573. loadImage(url: string, image: HTMLImageElement): void;
  71574. private _loadImageFromDBAsync;
  71575. private _saveImageIntoDBAsync;
  71576. private _checkVersionFromDB;
  71577. private _loadVersionFromDBAsync;
  71578. private _saveVersionIntoDBAsync;
  71579. /**
  71580. * Loads a file from database
  71581. * @param url defines the URL to load from
  71582. * @param sceneLoaded defines a callback to call on success
  71583. * @param progressCallBack defines a callback to call when progress changed
  71584. * @param errorCallback defines a callback to call on error
  71585. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71586. */
  71587. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71588. private _loadFileAsync;
  71589. private _saveFileAsync;
  71590. /**
  71591. * Validates if xhr data is correct
  71592. * @param xhr defines the request to validate
  71593. * @param dataType defines the expected data type
  71594. * @returns true if data is correct
  71595. */
  71596. private static _ValidateXHRData;
  71597. }
  71598. }
  71599. declare module BABYLON {
  71600. /** @hidden */
  71601. export var gpuUpdateParticlesPixelShader: {
  71602. name: string;
  71603. shader: string;
  71604. };
  71605. }
  71606. declare module BABYLON {
  71607. /** @hidden */
  71608. export var gpuUpdateParticlesVertexShader: {
  71609. name: string;
  71610. shader: string;
  71611. };
  71612. }
  71613. declare module BABYLON {
  71614. /** @hidden */
  71615. export var clipPlaneFragmentDeclaration2: {
  71616. name: string;
  71617. shader: string;
  71618. };
  71619. }
  71620. declare module BABYLON {
  71621. /** @hidden */
  71622. export var gpuRenderParticlesPixelShader: {
  71623. name: string;
  71624. shader: string;
  71625. };
  71626. }
  71627. declare module BABYLON {
  71628. /** @hidden */
  71629. export var clipPlaneVertexDeclaration2: {
  71630. name: string;
  71631. shader: string;
  71632. };
  71633. }
  71634. declare module BABYLON {
  71635. /** @hidden */
  71636. export var gpuRenderParticlesVertexShader: {
  71637. name: string;
  71638. shader: string;
  71639. };
  71640. }
  71641. declare module BABYLON {
  71642. /**
  71643. * This represents a GPU particle system in Babylon
  71644. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71645. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71646. */
  71647. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71648. /**
  71649. * The layer mask we are rendering the particles through.
  71650. */
  71651. layerMask: number;
  71652. private _capacity;
  71653. private _activeCount;
  71654. private _currentActiveCount;
  71655. private _accumulatedCount;
  71656. private _renderEffect;
  71657. private _updateEffect;
  71658. private _buffer0;
  71659. private _buffer1;
  71660. private _spriteBuffer;
  71661. private _updateVAO;
  71662. private _renderVAO;
  71663. private _targetIndex;
  71664. private _sourceBuffer;
  71665. private _targetBuffer;
  71666. private _currentRenderId;
  71667. private _started;
  71668. private _stopped;
  71669. private _timeDelta;
  71670. private _randomTexture;
  71671. private _randomTexture2;
  71672. private _attributesStrideSize;
  71673. private _updateEffectOptions;
  71674. private _randomTextureSize;
  71675. private _actualFrame;
  71676. private _customEffect;
  71677. private readonly _rawTextureWidth;
  71678. /**
  71679. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71680. */
  71681. static get IsSupported(): boolean;
  71682. /**
  71683. * An event triggered when the system is disposed.
  71684. */
  71685. onDisposeObservable: Observable<IParticleSystem>;
  71686. /**
  71687. * An event triggered when the system is stopped
  71688. */
  71689. onStoppedObservable: Observable<IParticleSystem>;
  71690. /**
  71691. * Gets the maximum number of particles active at the same time.
  71692. * @returns The max number of active particles.
  71693. */
  71694. getCapacity(): number;
  71695. /**
  71696. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71697. * to override the particles.
  71698. */
  71699. forceDepthWrite: boolean;
  71700. /**
  71701. * Gets or set the number of active particles
  71702. */
  71703. get activeParticleCount(): number;
  71704. set activeParticleCount(value: number);
  71705. private _preWarmDone;
  71706. /**
  71707. * Specifies if the particles are updated in emitter local space or world space.
  71708. */
  71709. isLocal: boolean;
  71710. /** Gets or sets a matrix to use to compute projection */
  71711. defaultProjectionMatrix: Matrix;
  71712. /**
  71713. * Is this system ready to be used/rendered
  71714. * @return true if the system is ready
  71715. */
  71716. isReady(): boolean;
  71717. /**
  71718. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71719. * @returns True if it has been started, otherwise false.
  71720. */
  71721. isStarted(): boolean;
  71722. /**
  71723. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71724. * @returns True if it has been stopped, otherwise false.
  71725. */
  71726. isStopped(): boolean;
  71727. /**
  71728. * Gets a boolean indicating that the system is stopping
  71729. * @returns true if the system is currently stopping
  71730. */
  71731. isStopping(): boolean;
  71732. /**
  71733. * Gets the number of particles active at the same time.
  71734. * @returns The number of active particles.
  71735. */
  71736. getActiveCount(): number;
  71737. /**
  71738. * Starts the particle system and begins to emit
  71739. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71740. */
  71741. start(delay?: number): void;
  71742. /**
  71743. * Stops the particle system.
  71744. */
  71745. stop(): void;
  71746. /**
  71747. * Remove all active particles
  71748. */
  71749. reset(): void;
  71750. /**
  71751. * Returns the string "GPUParticleSystem"
  71752. * @returns a string containing the class name
  71753. */
  71754. getClassName(): string;
  71755. /**
  71756. * Gets the custom effect used to render the particles
  71757. * @param blendMode Blend mode for which the effect should be retrieved
  71758. * @returns The effect
  71759. */
  71760. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71761. /**
  71762. * Sets the custom effect used to render the particles
  71763. * @param effect The effect to set
  71764. * @param blendMode Blend mode for which the effect should be set
  71765. */
  71766. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71767. /** @hidden */
  71768. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71769. /**
  71770. * Observable that will be called just before the particles are drawn
  71771. */
  71772. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71773. /**
  71774. * Gets the name of the particle vertex shader
  71775. */
  71776. get vertexShaderName(): string;
  71777. private _colorGradientsTexture;
  71778. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71779. /**
  71780. * Adds a new color gradient
  71781. * @param gradient defines the gradient to use (between 0 and 1)
  71782. * @param color1 defines the color to affect to the specified gradient
  71783. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71784. * @returns the current particle system
  71785. */
  71786. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71787. private _refreshColorGradient;
  71788. /** Force the system to rebuild all gradients that need to be resync */
  71789. forceRefreshGradients(): void;
  71790. /**
  71791. * Remove a specific color gradient
  71792. * @param gradient defines the gradient to remove
  71793. * @returns the current particle system
  71794. */
  71795. removeColorGradient(gradient: number): GPUParticleSystem;
  71796. private _angularSpeedGradientsTexture;
  71797. private _sizeGradientsTexture;
  71798. private _velocityGradientsTexture;
  71799. private _limitVelocityGradientsTexture;
  71800. private _dragGradientsTexture;
  71801. private _addFactorGradient;
  71802. /**
  71803. * Adds a new size gradient
  71804. * @param gradient defines the gradient to use (between 0 and 1)
  71805. * @param factor defines the size factor to affect to the specified gradient
  71806. * @returns the current particle system
  71807. */
  71808. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71809. /**
  71810. * Remove a specific size gradient
  71811. * @param gradient defines the gradient to remove
  71812. * @returns the current particle system
  71813. */
  71814. removeSizeGradient(gradient: number): GPUParticleSystem;
  71815. private _refreshFactorGradient;
  71816. /**
  71817. * Adds a new angular speed gradient
  71818. * @param gradient defines the gradient to use (between 0 and 1)
  71819. * @param factor defines the angular speed to affect to the specified gradient
  71820. * @returns the current particle system
  71821. */
  71822. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71823. /**
  71824. * Remove a specific angular speed gradient
  71825. * @param gradient defines the gradient to remove
  71826. * @returns the current particle system
  71827. */
  71828. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71829. /**
  71830. * Adds a new velocity gradient
  71831. * @param gradient defines the gradient to use (between 0 and 1)
  71832. * @param factor defines the velocity to affect to the specified gradient
  71833. * @returns the current particle system
  71834. */
  71835. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71836. /**
  71837. * Remove a specific velocity gradient
  71838. * @param gradient defines the gradient to remove
  71839. * @returns the current particle system
  71840. */
  71841. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71842. /**
  71843. * Adds a new limit velocity gradient
  71844. * @param gradient defines the gradient to use (between 0 and 1)
  71845. * @param factor defines the limit velocity value to affect to the specified gradient
  71846. * @returns the current particle system
  71847. */
  71848. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71849. /**
  71850. * Remove a specific limit velocity gradient
  71851. * @param gradient defines the gradient to remove
  71852. * @returns the current particle system
  71853. */
  71854. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71855. /**
  71856. * Adds a new drag gradient
  71857. * @param gradient defines the gradient to use (between 0 and 1)
  71858. * @param factor defines the drag value to affect to the specified gradient
  71859. * @returns the current particle system
  71860. */
  71861. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71862. /**
  71863. * Remove a specific drag gradient
  71864. * @param gradient defines the gradient to remove
  71865. * @returns the current particle system
  71866. */
  71867. removeDragGradient(gradient: number): GPUParticleSystem;
  71868. /**
  71869. * Not supported by GPUParticleSystem
  71870. * @param gradient defines the gradient to use (between 0 and 1)
  71871. * @param factor defines the emit rate value to affect to the specified gradient
  71872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71873. * @returns the current particle system
  71874. */
  71875. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71876. /**
  71877. * Not supported by GPUParticleSystem
  71878. * @param gradient defines the gradient to remove
  71879. * @returns the current particle system
  71880. */
  71881. removeEmitRateGradient(gradient: number): IParticleSystem;
  71882. /**
  71883. * Not supported by GPUParticleSystem
  71884. * @param gradient defines the gradient to use (between 0 and 1)
  71885. * @param factor defines the start size value to affect to the specified gradient
  71886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71887. * @returns the current particle system
  71888. */
  71889. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71890. /**
  71891. * Not supported by GPUParticleSystem
  71892. * @param gradient defines the gradient to remove
  71893. * @returns the current particle system
  71894. */
  71895. removeStartSizeGradient(gradient: number): IParticleSystem;
  71896. /**
  71897. * Not supported by GPUParticleSystem
  71898. * @param gradient defines the gradient to use (between 0 and 1)
  71899. * @param min defines the color remap minimal range
  71900. * @param max defines the color remap maximal range
  71901. * @returns the current particle system
  71902. */
  71903. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71904. /**
  71905. * Not supported by GPUParticleSystem
  71906. * @param gradient defines the gradient to remove
  71907. * @returns the current particle system
  71908. */
  71909. removeColorRemapGradient(): IParticleSystem;
  71910. /**
  71911. * Not supported by GPUParticleSystem
  71912. * @param gradient defines the gradient to use (between 0 and 1)
  71913. * @param min defines the alpha remap minimal range
  71914. * @param max defines the alpha remap maximal range
  71915. * @returns the current particle system
  71916. */
  71917. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71918. /**
  71919. * Not supported by GPUParticleSystem
  71920. * @param gradient defines the gradient to remove
  71921. * @returns the current particle system
  71922. */
  71923. removeAlphaRemapGradient(): IParticleSystem;
  71924. /**
  71925. * Not supported by GPUParticleSystem
  71926. * @param gradient defines the gradient to use (between 0 and 1)
  71927. * @param color defines the color to affect to the specified gradient
  71928. * @returns the current particle system
  71929. */
  71930. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71931. /**
  71932. * Not supported by GPUParticleSystem
  71933. * @param gradient defines the gradient to remove
  71934. * @returns the current particle system
  71935. */
  71936. removeRampGradient(): IParticleSystem;
  71937. /**
  71938. * Not supported by GPUParticleSystem
  71939. * @returns the list of ramp gradients
  71940. */
  71941. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71942. /**
  71943. * Not supported by GPUParticleSystem
  71944. * Gets or sets a boolean indicating that ramp gradients must be used
  71945. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71946. */
  71947. get useRampGradients(): boolean;
  71948. set useRampGradients(value: boolean);
  71949. /**
  71950. * Not supported by GPUParticleSystem
  71951. * @param gradient defines the gradient to use (between 0 and 1)
  71952. * @param factor defines the life time factor to affect to the specified gradient
  71953. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71954. * @returns the current particle system
  71955. */
  71956. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71957. /**
  71958. * Not supported by GPUParticleSystem
  71959. * @param gradient defines the gradient to remove
  71960. * @returns the current particle system
  71961. */
  71962. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71963. /**
  71964. * Instantiates a GPU particle system.
  71965. * 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.
  71966. * @param name The name of the particle system
  71967. * @param options The options used to create the system
  71968. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71969. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71970. * @param customEffect a custom effect used to change the way particles are rendered by default
  71971. */
  71972. constructor(name: string, options: Partial<{
  71973. capacity: number;
  71974. randomTextureSize: number;
  71975. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71976. protected _reset(): void;
  71977. private _createUpdateVAO;
  71978. private _createRenderVAO;
  71979. private _initialize;
  71980. /** @hidden */
  71981. _recreateUpdateEffect(): void;
  71982. private _getEffect;
  71983. /**
  71984. * Fill the defines array according to the current settings of the particle system
  71985. * @param defines Array to be updated
  71986. * @param blendMode blend mode to take into account when updating the array
  71987. */
  71988. fillDefines(defines: Array<string>, blendMode?: number): void;
  71989. /**
  71990. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71991. * @param uniforms Uniforms array to fill
  71992. * @param attributes Attributes array to fill
  71993. * @param samplers Samplers array to fill
  71994. */
  71995. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71996. /** @hidden */
  71997. _recreateRenderEffect(): Effect;
  71998. /**
  71999. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72000. * @param preWarm defines if we are in the pre-warmimg phase
  72001. */
  72002. animate(preWarm?: boolean): void;
  72003. private _createFactorGradientTexture;
  72004. private _createSizeGradientTexture;
  72005. private _createAngularSpeedGradientTexture;
  72006. private _createVelocityGradientTexture;
  72007. private _createLimitVelocityGradientTexture;
  72008. private _createDragGradientTexture;
  72009. private _createColorGradientTexture;
  72010. /**
  72011. * Renders the particle system in its current state
  72012. * @param preWarm defines if the system should only update the particles but not render them
  72013. * @returns the current number of particles
  72014. */
  72015. render(preWarm?: boolean): number;
  72016. /**
  72017. * Rebuilds the particle system
  72018. */
  72019. rebuild(): void;
  72020. private _releaseBuffers;
  72021. private _releaseVAOs;
  72022. /**
  72023. * Disposes the particle system and free the associated resources
  72024. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72025. */
  72026. dispose(disposeTexture?: boolean): void;
  72027. /**
  72028. * Clones the particle system.
  72029. * @param name The name of the cloned object
  72030. * @param newEmitter The new emitter to use
  72031. * @returns the cloned particle system
  72032. */
  72033. clone(name: string, newEmitter: any): GPUParticleSystem;
  72034. /**
  72035. * Serializes the particle system to a JSON object
  72036. * @param serializeTexture defines if the texture must be serialized as well
  72037. * @returns the JSON object
  72038. */
  72039. serialize(serializeTexture?: boolean): any;
  72040. /**
  72041. * Parses a JSON object to create a GPU particle system.
  72042. * @param parsedParticleSystem The JSON object to parse
  72043. * @param sceneOrEngine The scene or the engine to create the particle system in
  72044. * @param rootUrl The root url to use to load external dependencies like texture
  72045. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72046. * @returns the parsed GPU particle system
  72047. */
  72048. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72049. }
  72050. }
  72051. declare module BABYLON {
  72052. /**
  72053. * Represents a set of particle systems working together to create a specific effect
  72054. */
  72055. export class ParticleSystemSet implements IDisposable {
  72056. /**
  72057. * Gets or sets base Assets URL
  72058. */
  72059. static BaseAssetsUrl: string;
  72060. private _emitterCreationOptions;
  72061. private _emitterNode;
  72062. /**
  72063. * Gets the particle system list
  72064. */
  72065. systems: IParticleSystem[];
  72066. /**
  72067. * Gets the emitter node used with this set
  72068. */
  72069. get emitterNode(): Nullable<TransformNode>;
  72070. /**
  72071. * Creates a new emitter mesh as a sphere
  72072. * @param options defines the options used to create the sphere
  72073. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72074. * @param scene defines the hosting scene
  72075. */
  72076. setEmitterAsSphere(options: {
  72077. diameter: number;
  72078. segments: number;
  72079. color: Color3;
  72080. }, renderingGroupId: number, scene: Scene): void;
  72081. /**
  72082. * Starts all particle systems of the set
  72083. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72084. */
  72085. start(emitter?: AbstractMesh): void;
  72086. /**
  72087. * Release all associated resources
  72088. */
  72089. dispose(): void;
  72090. /**
  72091. * Serialize the set into a JSON compatible object
  72092. * @param serializeTexture defines if the texture must be serialized as well
  72093. * @returns a JSON compatible representation of the set
  72094. */
  72095. serialize(serializeTexture?: boolean): any;
  72096. /**
  72097. * Parse a new ParticleSystemSet from a serialized source
  72098. * @param data defines a JSON compatible representation of the set
  72099. * @param scene defines the hosting scene
  72100. * @param gpu defines if we want GPU particles or CPU particles
  72101. * @returns a new ParticleSystemSet
  72102. */
  72103. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72104. }
  72105. }
  72106. declare module BABYLON {
  72107. /**
  72108. * This class is made for on one-liner static method to help creating particle system set.
  72109. */
  72110. export class ParticleHelper {
  72111. /**
  72112. * Gets or sets base Assets URL
  72113. */
  72114. static BaseAssetsUrl: string;
  72115. /** Define the Url to load snippets */
  72116. static SnippetUrl: string;
  72117. /**
  72118. * Create a default particle system that you can tweak
  72119. * @param emitter defines the emitter to use
  72120. * @param capacity defines the system capacity (default is 500 particles)
  72121. * @param scene defines the hosting scene
  72122. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72123. * @returns the new Particle system
  72124. */
  72125. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72126. /**
  72127. * This is the main static method (one-liner) of this helper to create different particle systems
  72128. * @param type This string represents the type to the particle system to create
  72129. * @param scene The scene where the particle system should live
  72130. * @param gpu If the system will use gpu
  72131. * @returns the ParticleSystemSet created
  72132. */
  72133. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72134. /**
  72135. * Static function used to export a particle system to a ParticleSystemSet variable.
  72136. * Please note that the emitter shape is not exported
  72137. * @param systems defines the particle systems to export
  72138. * @returns the created particle system set
  72139. */
  72140. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72141. /**
  72142. * Creates a particle system from a snippet saved in a remote file
  72143. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72144. * @param url defines the url to load from
  72145. * @param scene defines the hosting scene
  72146. * @param gpu If the system will use gpu
  72147. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72148. * @returns a promise that will resolve to the new particle system
  72149. */
  72150. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72151. /**
  72152. * Creates a particle system from a snippet saved by the particle system editor
  72153. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72154. * @param scene defines the hosting scene
  72155. * @param gpu If the system will use gpu
  72156. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72157. * @returns a promise that will resolve to the new particle system
  72158. */
  72159. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72160. }
  72161. }
  72162. declare module BABYLON {
  72163. interface Engine {
  72164. /**
  72165. * Create an effect to use with particle systems.
  72166. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72167. * the particle system for which you want to create a custom effect in the last parameter
  72168. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72169. * @param uniformsNames defines a list of attribute names
  72170. * @param samplers defines an array of string used to represent textures
  72171. * @param defines defines the string containing the defines to use to compile the shaders
  72172. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72173. * @param onCompiled defines a function to call when the effect creation is successful
  72174. * @param onError defines a function to call when the effect creation has failed
  72175. * @param particleSystem the particle system you want to create the effect for
  72176. * @returns the new Effect
  72177. */
  72178. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72179. }
  72180. interface Mesh {
  72181. /**
  72182. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72183. * @returns an array of IParticleSystem
  72184. */
  72185. getEmittedParticleSystems(): IParticleSystem[];
  72186. /**
  72187. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72188. * @returns an array of IParticleSystem
  72189. */
  72190. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72191. }
  72192. }
  72193. declare module BABYLON {
  72194. /** Defines the 4 color options */
  72195. export enum PointColor {
  72196. /** color value */
  72197. Color = 2,
  72198. /** uv value */
  72199. UV = 1,
  72200. /** random value */
  72201. Random = 0,
  72202. /** stated value */
  72203. Stated = 3
  72204. }
  72205. /**
  72206. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72207. * 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.
  72208. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72209. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72210. *
  72211. * Full documentation here : TO BE ENTERED
  72212. */
  72213. export class PointsCloudSystem implements IDisposable {
  72214. /**
  72215. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72216. * Example : var p = SPS.particles[i];
  72217. */
  72218. particles: CloudPoint[];
  72219. /**
  72220. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72221. */
  72222. nbParticles: number;
  72223. /**
  72224. * This a counter for your own usage. It's not set by any SPS functions.
  72225. */
  72226. counter: number;
  72227. /**
  72228. * The PCS name. This name is also given to the underlying mesh.
  72229. */
  72230. name: string;
  72231. /**
  72232. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72233. */
  72234. mesh: Mesh;
  72235. /**
  72236. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72237. * Please read :
  72238. */
  72239. vars: any;
  72240. /**
  72241. * @hidden
  72242. */
  72243. _size: number;
  72244. private _scene;
  72245. private _promises;
  72246. private _positions;
  72247. private _indices;
  72248. private _normals;
  72249. private _colors;
  72250. private _uvs;
  72251. private _indices32;
  72252. private _positions32;
  72253. private _colors32;
  72254. private _uvs32;
  72255. private _updatable;
  72256. private _isVisibilityBoxLocked;
  72257. private _alwaysVisible;
  72258. private _groups;
  72259. private _groupCounter;
  72260. private _computeParticleColor;
  72261. private _computeParticleTexture;
  72262. private _computeParticleRotation;
  72263. private _computeBoundingBox;
  72264. private _isReady;
  72265. /**
  72266. * Creates a PCS (Points Cloud System) object
  72267. * @param name (String) is the PCS name, this will be the underlying mesh name
  72268. * @param pointSize (number) is the size for each point
  72269. * @param scene (Scene) is the scene in which the PCS is added
  72270. * @param options defines the options of the PCS e.g.
  72271. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72272. */
  72273. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72274. updatable?: boolean;
  72275. });
  72276. /**
  72277. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72278. * If no points were added to the PCS, the returned mesh is just a single point.
  72279. * @returns a promise for the created mesh
  72280. */
  72281. buildMeshAsync(): Promise<Mesh>;
  72282. /**
  72283. * @hidden
  72284. */
  72285. private _buildMesh;
  72286. private _addParticle;
  72287. private _randomUnitVector;
  72288. private _getColorIndicesForCoord;
  72289. private _setPointsColorOrUV;
  72290. private _colorFromTexture;
  72291. private _calculateDensity;
  72292. /**
  72293. * Adds points to the PCS in random positions within a unit sphere
  72294. * @param nb (positive integer) the number of particles to be created from this model
  72295. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72296. * @returns the number of groups in the system
  72297. */
  72298. addPoints(nb: number, pointFunction?: any): number;
  72299. /**
  72300. * Adds points to the PCS from the surface of the model shape
  72301. * @param mesh is any Mesh object that will be used as a surface model for the points
  72302. * @param nb (positive integer) the number of particles to be created from this model
  72303. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72304. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72305. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72306. * @returns the number of groups in the system
  72307. */
  72308. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72309. /**
  72310. * Adds points to the PCS inside the model shape
  72311. * @param mesh is any Mesh object that will be used as a surface model for the points
  72312. * @param nb (positive integer) the number of particles to be created from this model
  72313. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72314. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72315. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72316. * @returns the number of groups in the system
  72317. */
  72318. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72319. /**
  72320. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72321. * This method calls `updateParticle()` for each particle of the SPS.
  72322. * For an animated SPS, it is usually called within the render loop.
  72323. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72324. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72325. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72326. * @returns the PCS.
  72327. */
  72328. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72329. /**
  72330. * Disposes the PCS.
  72331. */
  72332. dispose(): void;
  72333. /**
  72334. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72335. * doc :
  72336. * @returns the PCS.
  72337. */
  72338. refreshVisibleSize(): PointsCloudSystem;
  72339. /**
  72340. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72341. * @param size the size (float) of the visibility box
  72342. * note : this doesn't lock the PCS mesh bounding box.
  72343. * doc :
  72344. */
  72345. setVisibilityBox(size: number): void;
  72346. /**
  72347. * Gets whether the PCS is always visible or not
  72348. * doc :
  72349. */
  72350. get isAlwaysVisible(): boolean;
  72351. /**
  72352. * Sets the PCS as always visible or not
  72353. * doc :
  72354. */
  72355. set isAlwaysVisible(val: boolean);
  72356. /**
  72357. * Tells to `setParticles()` to compute the particle rotations or not
  72358. * Default value : false. The PCS is faster when it's set to false
  72359. * Note : particle rotations are only applied to parent particles
  72360. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72361. */
  72362. set computeParticleRotation(val: boolean);
  72363. /**
  72364. * Tells to `setParticles()` to compute the particle colors or not.
  72365. * Default value : true. The PCS is faster when it's set to false.
  72366. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72367. */
  72368. set computeParticleColor(val: boolean);
  72369. set computeParticleTexture(val: boolean);
  72370. /**
  72371. * Gets if `setParticles()` computes the particle colors or not.
  72372. * Default value : false. The PCS is faster when it's set to false.
  72373. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72374. */
  72375. get computeParticleColor(): boolean;
  72376. /**
  72377. * Gets if `setParticles()` computes the particle textures or not.
  72378. * Default value : false. The PCS is faster when it's set to false.
  72379. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72380. */
  72381. get computeParticleTexture(): boolean;
  72382. /**
  72383. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72384. */
  72385. set computeBoundingBox(val: boolean);
  72386. /**
  72387. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72388. */
  72389. get computeBoundingBox(): boolean;
  72390. /**
  72391. * This function does nothing. It may be overwritten to set all the particle first values.
  72392. * The PCS doesn't call this function, you may have to call it by your own.
  72393. * doc :
  72394. */
  72395. initParticles(): void;
  72396. /**
  72397. * This function does nothing. It may be overwritten to recycle a particle
  72398. * The PCS doesn't call this function, you can to call it
  72399. * doc :
  72400. * @param particle The particle to recycle
  72401. * @returns the recycled particle
  72402. */
  72403. recycleParticle(particle: CloudPoint): CloudPoint;
  72404. /**
  72405. * Updates a particle : this function should be overwritten by the user.
  72406. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72407. * doc :
  72408. * @example : just set a particle position or velocity and recycle conditions
  72409. * @param particle The particle to update
  72410. * @returns the updated particle
  72411. */
  72412. updateParticle(particle: CloudPoint): CloudPoint;
  72413. /**
  72414. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72415. * This does nothing and may be overwritten by the user.
  72416. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72417. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72418. * @param update the boolean update value actually passed to setParticles()
  72419. */
  72420. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72421. /**
  72422. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72423. * This will be passed three parameters.
  72424. * This does nothing and may be overwritten by the user.
  72425. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72426. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72427. * @param update the boolean update value actually passed to setParticles()
  72428. */
  72429. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72430. }
  72431. }
  72432. declare module BABYLON {
  72433. /**
  72434. * Represents one particle of a points cloud system.
  72435. */
  72436. export class CloudPoint {
  72437. /**
  72438. * particle global index
  72439. */
  72440. idx: number;
  72441. /**
  72442. * The color of the particle
  72443. */
  72444. color: Nullable<Color4>;
  72445. /**
  72446. * The world space position of the particle.
  72447. */
  72448. position: Vector3;
  72449. /**
  72450. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72451. */
  72452. rotation: Vector3;
  72453. /**
  72454. * The world space rotation quaternion of the particle.
  72455. */
  72456. rotationQuaternion: Nullable<Quaternion>;
  72457. /**
  72458. * The uv of the particle.
  72459. */
  72460. uv: Nullable<Vector2>;
  72461. /**
  72462. * The current speed of the particle.
  72463. */
  72464. velocity: Vector3;
  72465. /**
  72466. * The pivot point in the particle local space.
  72467. */
  72468. pivot: Vector3;
  72469. /**
  72470. * Must the particle be translated from its pivot point in its local space ?
  72471. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72472. * Default : false
  72473. */
  72474. translateFromPivot: boolean;
  72475. /**
  72476. * Index of this particle in the global "positions" array (Internal use)
  72477. * @hidden
  72478. */
  72479. _pos: number;
  72480. /**
  72481. * @hidden Index of this particle in the global "indices" array (Internal use)
  72482. */
  72483. _ind: number;
  72484. /**
  72485. * Group this particle belongs to
  72486. */
  72487. _group: PointsGroup;
  72488. /**
  72489. * Group id of this particle
  72490. */
  72491. groupId: number;
  72492. /**
  72493. * Index of the particle in its group id (Internal use)
  72494. */
  72495. idxInGroup: number;
  72496. /**
  72497. * @hidden Particle BoundingInfo object (Internal use)
  72498. */
  72499. _boundingInfo: BoundingInfo;
  72500. /**
  72501. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72502. */
  72503. _pcs: PointsCloudSystem;
  72504. /**
  72505. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72506. */
  72507. _stillInvisible: boolean;
  72508. /**
  72509. * @hidden Last computed particle rotation matrix
  72510. */
  72511. _rotationMatrix: number[];
  72512. /**
  72513. * Parent particle Id, if any.
  72514. * Default null.
  72515. */
  72516. parentId: Nullable<number>;
  72517. /**
  72518. * @hidden Internal global position in the PCS.
  72519. */
  72520. _globalPosition: Vector3;
  72521. /**
  72522. * Creates a Point Cloud object.
  72523. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72524. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72525. * @param group (PointsGroup) is the group the particle belongs to
  72526. * @param groupId (integer) is the group identifier in the PCS.
  72527. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72528. * @param pcs defines the PCS it is associated to
  72529. */
  72530. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72531. /**
  72532. * get point size
  72533. */
  72534. get size(): Vector3;
  72535. /**
  72536. * Set point size
  72537. */
  72538. set size(scale: Vector3);
  72539. /**
  72540. * Legacy support, changed quaternion to rotationQuaternion
  72541. */
  72542. get quaternion(): Nullable<Quaternion>;
  72543. /**
  72544. * Legacy support, changed quaternion to rotationQuaternion
  72545. */
  72546. set quaternion(q: Nullable<Quaternion>);
  72547. /**
  72548. * Returns a boolean. True if the particle intersects a mesh, else false
  72549. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72550. * @param target is the object (point or mesh) what the intersection is computed against
  72551. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72552. * @returns true if it intersects
  72553. */
  72554. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72555. /**
  72556. * get the rotation matrix of the particle
  72557. * @hidden
  72558. */
  72559. getRotationMatrix(m: Matrix): void;
  72560. }
  72561. /**
  72562. * Represents a group of points in a points cloud system
  72563. * * PCS internal tool, don't use it manually.
  72564. */
  72565. export class PointsGroup {
  72566. /**
  72567. * The group id
  72568. * @hidden
  72569. */
  72570. groupID: number;
  72571. /**
  72572. * image data for group (internal use)
  72573. * @hidden
  72574. */
  72575. _groupImageData: Nullable<ArrayBufferView>;
  72576. /**
  72577. * Image Width (internal use)
  72578. * @hidden
  72579. */
  72580. _groupImgWidth: number;
  72581. /**
  72582. * Image Height (internal use)
  72583. * @hidden
  72584. */
  72585. _groupImgHeight: number;
  72586. /**
  72587. * Custom position function (internal use)
  72588. * @hidden
  72589. */
  72590. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72591. /**
  72592. * density per facet for surface points
  72593. * @hidden
  72594. */
  72595. _groupDensity: number[];
  72596. /**
  72597. * Only when points are colored by texture carries pointer to texture list array
  72598. * @hidden
  72599. */
  72600. _textureNb: number;
  72601. /**
  72602. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72603. * PCS internal tool, don't use it manually.
  72604. * @hidden
  72605. */
  72606. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72607. }
  72608. }
  72609. declare module BABYLON {
  72610. interface Scene {
  72611. /** @hidden (Backing field) */
  72612. _physicsEngine: Nullable<IPhysicsEngine>;
  72613. /** @hidden */
  72614. _physicsTimeAccumulator: number;
  72615. /**
  72616. * Gets the current physics engine
  72617. * @returns a IPhysicsEngine or null if none attached
  72618. */
  72619. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72620. /**
  72621. * Enables physics to the current scene
  72622. * @param gravity defines the scene's gravity for the physics engine
  72623. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72624. * @return a boolean indicating if the physics engine was initialized
  72625. */
  72626. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72627. /**
  72628. * Disables and disposes the physics engine associated with the scene
  72629. */
  72630. disablePhysicsEngine(): void;
  72631. /**
  72632. * Gets a boolean indicating if there is an active physics engine
  72633. * @returns a boolean indicating if there is an active physics engine
  72634. */
  72635. isPhysicsEnabled(): boolean;
  72636. /**
  72637. * Deletes a physics compound impostor
  72638. * @param compound defines the compound to delete
  72639. */
  72640. deleteCompoundImpostor(compound: any): void;
  72641. /**
  72642. * An event triggered when physic simulation is about to be run
  72643. */
  72644. onBeforePhysicsObservable: Observable<Scene>;
  72645. /**
  72646. * An event triggered when physic simulation has been done
  72647. */
  72648. onAfterPhysicsObservable: Observable<Scene>;
  72649. }
  72650. interface AbstractMesh {
  72651. /** @hidden */
  72652. _physicsImpostor: Nullable<PhysicsImpostor>;
  72653. /**
  72654. * Gets or sets impostor used for physic simulation
  72655. * @see https://doc.babylonjs.com/features/physics_engine
  72656. */
  72657. physicsImpostor: Nullable<PhysicsImpostor>;
  72658. /**
  72659. * Gets the current physics impostor
  72660. * @see https://doc.babylonjs.com/features/physics_engine
  72661. * @returns a physics impostor or null
  72662. */
  72663. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72664. /** Apply a physic impulse to the mesh
  72665. * @param force defines the force to apply
  72666. * @param contactPoint defines where to apply the force
  72667. * @returns the current mesh
  72668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72669. */
  72670. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72671. /**
  72672. * Creates a physic joint between two meshes
  72673. * @param otherMesh defines the other mesh to use
  72674. * @param pivot1 defines the pivot to use on this mesh
  72675. * @param pivot2 defines the pivot to use on the other mesh
  72676. * @param options defines additional options (can be plugin dependent)
  72677. * @returns the current mesh
  72678. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72679. */
  72680. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72681. /** @hidden */
  72682. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72683. }
  72684. /**
  72685. * Defines the physics engine scene component responsible to manage a physics engine
  72686. */
  72687. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72688. /**
  72689. * The component name helpful to identify the component in the list of scene components.
  72690. */
  72691. readonly name: string;
  72692. /**
  72693. * The scene the component belongs to.
  72694. */
  72695. scene: Scene;
  72696. /**
  72697. * Creates a new instance of the component for the given scene
  72698. * @param scene Defines the scene to register the component in
  72699. */
  72700. constructor(scene: Scene);
  72701. /**
  72702. * Registers the component in a given scene
  72703. */
  72704. register(): void;
  72705. /**
  72706. * Rebuilds the elements related to this component in case of
  72707. * context lost for instance.
  72708. */
  72709. rebuild(): void;
  72710. /**
  72711. * Disposes the component and the associated ressources
  72712. */
  72713. dispose(): void;
  72714. }
  72715. }
  72716. declare module BABYLON {
  72717. /**
  72718. * A helper for physics simulations
  72719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72720. */
  72721. export class PhysicsHelper {
  72722. private _scene;
  72723. private _physicsEngine;
  72724. /**
  72725. * Initializes the Physics helper
  72726. * @param scene Babylon.js scene
  72727. */
  72728. constructor(scene: Scene);
  72729. /**
  72730. * Applies a radial explosion impulse
  72731. * @param origin the origin of the explosion
  72732. * @param radiusOrEventOptions the radius or the options of radial explosion
  72733. * @param strength the explosion strength
  72734. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72735. * @returns A physics radial explosion event, or null
  72736. */
  72737. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72738. /**
  72739. * Applies a radial explosion force
  72740. * @param origin the origin of the explosion
  72741. * @param radiusOrEventOptions the radius or the options of radial explosion
  72742. * @param strength the explosion strength
  72743. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72744. * @returns A physics radial explosion event, or null
  72745. */
  72746. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72747. /**
  72748. * Creates a gravitational field
  72749. * @param origin the origin of the explosion
  72750. * @param radiusOrEventOptions the radius or the options of radial explosion
  72751. * @param strength the explosion strength
  72752. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72753. * @returns A physics gravitational field event, or null
  72754. */
  72755. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72756. /**
  72757. * Creates a physics updraft event
  72758. * @param origin the origin of the updraft
  72759. * @param radiusOrEventOptions the radius or the options of the updraft
  72760. * @param strength the strength of the updraft
  72761. * @param height the height of the updraft
  72762. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72763. * @returns A physics updraft event, or null
  72764. */
  72765. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72766. /**
  72767. * Creates a physics vortex event
  72768. * @param origin the of the vortex
  72769. * @param radiusOrEventOptions the radius or the options of the vortex
  72770. * @param strength the strength of the vortex
  72771. * @param height the height of the vortex
  72772. * @returns a Physics vortex event, or null
  72773. * A physics vortex event or null
  72774. */
  72775. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72776. }
  72777. /**
  72778. * Represents a physics radial explosion event
  72779. */
  72780. class PhysicsRadialExplosionEvent {
  72781. private _scene;
  72782. private _options;
  72783. private _sphere;
  72784. private _dataFetched;
  72785. /**
  72786. * Initializes a radial explosioin event
  72787. * @param _scene BabylonJS scene
  72788. * @param _options The options for the vortex event
  72789. */
  72790. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72791. /**
  72792. * Returns the data related to the radial explosion event (sphere).
  72793. * @returns The radial explosion event data
  72794. */
  72795. getData(): PhysicsRadialExplosionEventData;
  72796. /**
  72797. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72798. * @param impostor A physics imposter
  72799. * @param origin the origin of the explosion
  72800. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72801. */
  72802. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72803. /**
  72804. * Triggers affecterd impostors callbacks
  72805. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72806. */
  72807. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72808. /**
  72809. * Disposes the sphere.
  72810. * @param force Specifies if the sphere should be disposed by force
  72811. */
  72812. dispose(force?: boolean): void;
  72813. /*** Helpers ***/
  72814. private _prepareSphere;
  72815. private _intersectsWithSphere;
  72816. }
  72817. /**
  72818. * Represents a gravitational field event
  72819. */
  72820. class PhysicsGravitationalFieldEvent {
  72821. private _physicsHelper;
  72822. private _scene;
  72823. private _origin;
  72824. private _options;
  72825. private _tickCallback;
  72826. private _sphere;
  72827. private _dataFetched;
  72828. /**
  72829. * Initializes the physics gravitational field event
  72830. * @param _physicsHelper A physics helper
  72831. * @param _scene BabylonJS scene
  72832. * @param _origin The origin position of the gravitational field event
  72833. * @param _options The options for the vortex event
  72834. */
  72835. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72836. /**
  72837. * Returns the data related to the gravitational field event (sphere).
  72838. * @returns A gravitational field event
  72839. */
  72840. getData(): PhysicsGravitationalFieldEventData;
  72841. /**
  72842. * Enables the gravitational field.
  72843. */
  72844. enable(): void;
  72845. /**
  72846. * Disables the gravitational field.
  72847. */
  72848. disable(): void;
  72849. /**
  72850. * Disposes the sphere.
  72851. * @param force The force to dispose from the gravitational field event
  72852. */
  72853. dispose(force?: boolean): void;
  72854. private _tick;
  72855. }
  72856. /**
  72857. * Represents a physics updraft event
  72858. */
  72859. class PhysicsUpdraftEvent {
  72860. private _scene;
  72861. private _origin;
  72862. private _options;
  72863. private _physicsEngine;
  72864. private _originTop;
  72865. private _originDirection;
  72866. private _tickCallback;
  72867. private _cylinder;
  72868. private _cylinderPosition;
  72869. private _dataFetched;
  72870. /**
  72871. * Initializes the physics updraft event
  72872. * @param _scene BabylonJS scene
  72873. * @param _origin The origin position of the updraft
  72874. * @param _options The options for the updraft event
  72875. */
  72876. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72877. /**
  72878. * Returns the data related to the updraft event (cylinder).
  72879. * @returns A physics updraft event
  72880. */
  72881. getData(): PhysicsUpdraftEventData;
  72882. /**
  72883. * Enables the updraft.
  72884. */
  72885. enable(): void;
  72886. /**
  72887. * Disables the updraft.
  72888. */
  72889. disable(): void;
  72890. /**
  72891. * Disposes the cylinder.
  72892. * @param force Specifies if the updraft should be disposed by force
  72893. */
  72894. dispose(force?: boolean): void;
  72895. private getImpostorHitData;
  72896. private _tick;
  72897. /*** Helpers ***/
  72898. private _prepareCylinder;
  72899. private _intersectsWithCylinder;
  72900. }
  72901. /**
  72902. * Represents a physics vortex event
  72903. */
  72904. class PhysicsVortexEvent {
  72905. private _scene;
  72906. private _origin;
  72907. private _options;
  72908. private _physicsEngine;
  72909. private _originTop;
  72910. private _tickCallback;
  72911. private _cylinder;
  72912. private _cylinderPosition;
  72913. private _dataFetched;
  72914. /**
  72915. * Initializes the physics vortex event
  72916. * @param _scene The BabylonJS scene
  72917. * @param _origin The origin position of the vortex
  72918. * @param _options The options for the vortex event
  72919. */
  72920. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72921. /**
  72922. * Returns the data related to the vortex event (cylinder).
  72923. * @returns The physics vortex event data
  72924. */
  72925. getData(): PhysicsVortexEventData;
  72926. /**
  72927. * Enables the vortex.
  72928. */
  72929. enable(): void;
  72930. /**
  72931. * Disables the cortex.
  72932. */
  72933. disable(): void;
  72934. /**
  72935. * Disposes the sphere.
  72936. * @param force
  72937. */
  72938. dispose(force?: boolean): void;
  72939. private getImpostorHitData;
  72940. private _tick;
  72941. /*** Helpers ***/
  72942. private _prepareCylinder;
  72943. private _intersectsWithCylinder;
  72944. }
  72945. /**
  72946. * Options fot the radial explosion event
  72947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72948. */
  72949. export class PhysicsRadialExplosionEventOptions {
  72950. /**
  72951. * The radius of the sphere for the radial explosion.
  72952. */
  72953. radius: number;
  72954. /**
  72955. * The strenth of the explosion.
  72956. */
  72957. strength: number;
  72958. /**
  72959. * The strenght of the force in correspondence to the distance of the affected object
  72960. */
  72961. falloff: PhysicsRadialImpulseFalloff;
  72962. /**
  72963. * Sphere options for the radial explosion.
  72964. */
  72965. sphere: {
  72966. segments: number;
  72967. diameter: number;
  72968. };
  72969. /**
  72970. * Sphere options for the radial explosion.
  72971. */
  72972. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72973. }
  72974. /**
  72975. * Options fot the updraft event
  72976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72977. */
  72978. export class PhysicsUpdraftEventOptions {
  72979. /**
  72980. * The radius of the cylinder for the vortex
  72981. */
  72982. radius: number;
  72983. /**
  72984. * The strenth of the updraft.
  72985. */
  72986. strength: number;
  72987. /**
  72988. * The height of the cylinder for the updraft.
  72989. */
  72990. height: number;
  72991. /**
  72992. * The mode for the the updraft.
  72993. */
  72994. updraftMode: PhysicsUpdraftMode;
  72995. }
  72996. /**
  72997. * Options fot the vortex event
  72998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72999. */
  73000. export class PhysicsVortexEventOptions {
  73001. /**
  73002. * The radius of the cylinder for the vortex
  73003. */
  73004. radius: number;
  73005. /**
  73006. * The strenth of the vortex.
  73007. */
  73008. strength: number;
  73009. /**
  73010. * The height of the cylinder for the vortex.
  73011. */
  73012. height: number;
  73013. /**
  73014. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73015. */
  73016. centripetalForceThreshold: number;
  73017. /**
  73018. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73019. */
  73020. centripetalForceMultiplier: number;
  73021. /**
  73022. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73023. */
  73024. centrifugalForceMultiplier: number;
  73025. /**
  73026. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73027. */
  73028. updraftForceMultiplier: number;
  73029. }
  73030. /**
  73031. * The strenght of the force in correspondence to the distance of the affected object
  73032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73033. */
  73034. export enum PhysicsRadialImpulseFalloff {
  73035. /** Defines that impulse is constant in strength across it's whole radius */
  73036. Constant = 0,
  73037. /** Defines that impulse gets weaker if it's further from the origin */
  73038. Linear = 1
  73039. }
  73040. /**
  73041. * The strength of the force in correspondence to the distance of the affected object
  73042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73043. */
  73044. export enum PhysicsUpdraftMode {
  73045. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73046. Center = 0,
  73047. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73048. Perpendicular = 1
  73049. }
  73050. /**
  73051. * Interface for a physics hit data
  73052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73053. */
  73054. export interface PhysicsHitData {
  73055. /**
  73056. * The force applied at the contact point
  73057. */
  73058. force: Vector3;
  73059. /**
  73060. * The contact point
  73061. */
  73062. contactPoint: Vector3;
  73063. /**
  73064. * The distance from the origin to the contact point
  73065. */
  73066. distanceFromOrigin: number;
  73067. }
  73068. /**
  73069. * Interface for radial explosion event data
  73070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73071. */
  73072. export interface PhysicsRadialExplosionEventData {
  73073. /**
  73074. * A sphere used for the radial explosion event
  73075. */
  73076. sphere: Mesh;
  73077. }
  73078. /**
  73079. * Interface for gravitational field event data
  73080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73081. */
  73082. export interface PhysicsGravitationalFieldEventData {
  73083. /**
  73084. * A sphere mesh used for the gravitational field event
  73085. */
  73086. sphere: Mesh;
  73087. }
  73088. /**
  73089. * Interface for updraft event data
  73090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73091. */
  73092. export interface PhysicsUpdraftEventData {
  73093. /**
  73094. * A cylinder used for the updraft event
  73095. */
  73096. cylinder: Mesh;
  73097. }
  73098. /**
  73099. * Interface for vortex event data
  73100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73101. */
  73102. export interface PhysicsVortexEventData {
  73103. /**
  73104. * A cylinder used for the vortex event
  73105. */
  73106. cylinder: Mesh;
  73107. }
  73108. /**
  73109. * Interface for an affected physics impostor
  73110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73111. */
  73112. export interface PhysicsAffectedImpostorWithData {
  73113. /**
  73114. * The impostor affected by the effect
  73115. */
  73116. impostor: PhysicsImpostor;
  73117. /**
  73118. * The data about the hit/horce from the explosion
  73119. */
  73120. hitData: PhysicsHitData;
  73121. }
  73122. }
  73123. declare module BABYLON {
  73124. /** @hidden */
  73125. export var blackAndWhitePixelShader: {
  73126. name: string;
  73127. shader: string;
  73128. };
  73129. }
  73130. declare module BABYLON {
  73131. /**
  73132. * Post process used to render in black and white
  73133. */
  73134. export class BlackAndWhitePostProcess extends PostProcess {
  73135. /**
  73136. * Linear about to convert he result to black and white (default: 1)
  73137. */
  73138. degree: number;
  73139. /**
  73140. * Gets a string identifying the name of the class
  73141. * @returns "BlackAndWhitePostProcess" string
  73142. */
  73143. getClassName(): string;
  73144. /**
  73145. * Creates a black and white post process
  73146. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73147. * @param name The name of the effect.
  73148. * @param options The required width/height ratio to downsize to before computing the render pass.
  73149. * @param camera The camera to apply the render pass to.
  73150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73151. * @param engine The engine which the post process will be applied. (default: current engine)
  73152. * @param reusable If the post process can be reused on the same frame. (default: false)
  73153. */
  73154. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73155. /** @hidden */
  73156. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73157. }
  73158. }
  73159. declare module BABYLON {
  73160. /**
  73161. * This represents a set of one or more post processes in Babylon.
  73162. * A post process can be used to apply a shader to a texture after it is rendered.
  73163. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73164. */
  73165. export class PostProcessRenderEffect {
  73166. private _postProcesses;
  73167. private _getPostProcesses;
  73168. private _singleInstance;
  73169. private _cameras;
  73170. private _indicesForCamera;
  73171. /**
  73172. * Name of the effect
  73173. * @hidden
  73174. */
  73175. _name: string;
  73176. /**
  73177. * Instantiates a post process render effect.
  73178. * A post process can be used to apply a shader to a texture after it is rendered.
  73179. * @param engine The engine the effect is tied to
  73180. * @param name The name of the effect
  73181. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73182. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73183. */
  73184. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73185. /**
  73186. * Checks if all the post processes in the effect are supported.
  73187. */
  73188. get isSupported(): boolean;
  73189. /**
  73190. * Updates the current state of the effect
  73191. * @hidden
  73192. */
  73193. _update(): void;
  73194. /**
  73195. * Attaches the effect on cameras
  73196. * @param cameras The camera to attach to.
  73197. * @hidden
  73198. */
  73199. _attachCameras(cameras: Camera): void;
  73200. /**
  73201. * Attaches the effect on cameras
  73202. * @param cameras The camera to attach to.
  73203. * @hidden
  73204. */
  73205. _attachCameras(cameras: Camera[]): void;
  73206. /**
  73207. * Detaches the effect on cameras
  73208. * @param cameras The camera to detatch from.
  73209. * @hidden
  73210. */
  73211. _detachCameras(cameras: Camera): void;
  73212. /**
  73213. * Detatches the effect on cameras
  73214. * @param cameras The camera to detatch from.
  73215. * @hidden
  73216. */
  73217. _detachCameras(cameras: Camera[]): void;
  73218. /**
  73219. * Enables the effect on given cameras
  73220. * @param cameras The camera to enable.
  73221. * @hidden
  73222. */
  73223. _enable(cameras: Camera): void;
  73224. /**
  73225. * Enables the effect on given cameras
  73226. * @param cameras The camera to enable.
  73227. * @hidden
  73228. */
  73229. _enable(cameras: Nullable<Camera[]>): void;
  73230. /**
  73231. * Disables the effect on the given cameras
  73232. * @param cameras The camera to disable.
  73233. * @hidden
  73234. */
  73235. _disable(cameras: Camera): void;
  73236. /**
  73237. * Disables the effect on the given cameras
  73238. * @param cameras The camera to disable.
  73239. * @hidden
  73240. */
  73241. _disable(cameras: Nullable<Camera[]>): void;
  73242. /**
  73243. * Gets a list of the post processes contained in the effect.
  73244. * @param camera The camera to get the post processes on.
  73245. * @returns The list of the post processes in the effect.
  73246. */
  73247. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73248. }
  73249. }
  73250. declare module BABYLON {
  73251. /** @hidden */
  73252. export var extractHighlightsPixelShader: {
  73253. name: string;
  73254. shader: string;
  73255. };
  73256. }
  73257. declare module BABYLON {
  73258. /**
  73259. * 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.
  73260. */
  73261. export class ExtractHighlightsPostProcess extends PostProcess {
  73262. /**
  73263. * The luminance threshold, pixels below this value will be set to black.
  73264. */
  73265. threshold: number;
  73266. /** @hidden */
  73267. _exposure: number;
  73268. /**
  73269. * Post process which has the input texture to be used when performing highlight extraction
  73270. * @hidden
  73271. */
  73272. _inputPostProcess: Nullable<PostProcess>;
  73273. /**
  73274. * Gets a string identifying the name of the class
  73275. * @returns "ExtractHighlightsPostProcess" string
  73276. */
  73277. getClassName(): string;
  73278. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73279. }
  73280. }
  73281. declare module BABYLON {
  73282. /** @hidden */
  73283. export var bloomMergePixelShader: {
  73284. name: string;
  73285. shader: string;
  73286. };
  73287. }
  73288. declare module BABYLON {
  73289. /**
  73290. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73291. */
  73292. export class BloomMergePostProcess extends PostProcess {
  73293. /** Weight of the bloom to be added to the original input. */
  73294. weight: number;
  73295. /**
  73296. * Gets a string identifying the name of the class
  73297. * @returns "BloomMergePostProcess" string
  73298. */
  73299. getClassName(): string;
  73300. /**
  73301. * Creates a new instance of @see BloomMergePostProcess
  73302. * @param name The name of the effect.
  73303. * @param originalFromInput Post process which's input will be used for the merge.
  73304. * @param blurred Blurred highlights post process which's output will be used.
  73305. * @param weight Weight of the bloom to be added to the original input.
  73306. * @param options The required width/height ratio to downsize to before computing the render pass.
  73307. * @param camera The camera to apply the render pass to.
  73308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73309. * @param engine The engine which the post process will be applied. (default: current engine)
  73310. * @param reusable If the post process can be reused on the same frame. (default: false)
  73311. * @param textureType Type of textures used when performing the post process. (default: 0)
  73312. * @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)
  73313. */
  73314. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73315. /** Weight of the bloom to be added to the original input. */
  73316. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73317. }
  73318. }
  73319. declare module BABYLON {
  73320. /**
  73321. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73322. */
  73323. export class BloomEffect extends PostProcessRenderEffect {
  73324. private bloomScale;
  73325. /**
  73326. * @hidden Internal
  73327. */
  73328. _effects: Array<PostProcess>;
  73329. /**
  73330. * @hidden Internal
  73331. */
  73332. _downscale: ExtractHighlightsPostProcess;
  73333. private _blurX;
  73334. private _blurY;
  73335. private _merge;
  73336. /**
  73337. * The luminance threshold to find bright areas of the image to bloom.
  73338. */
  73339. get threshold(): number;
  73340. set threshold(value: number);
  73341. /**
  73342. * The strength of the bloom.
  73343. */
  73344. get weight(): number;
  73345. set weight(value: number);
  73346. /**
  73347. * Specifies the size of the bloom blur kernel, relative to the final output size
  73348. */
  73349. get kernel(): number;
  73350. set kernel(value: number);
  73351. /**
  73352. * Creates a new instance of @see BloomEffect
  73353. * @param scene The scene the effect belongs to.
  73354. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73355. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73356. * @param bloomWeight The the strength of bloom.
  73357. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73358. * @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)
  73359. */
  73360. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73361. /**
  73362. * Disposes each of the internal effects for a given camera.
  73363. * @param camera The camera to dispose the effect on.
  73364. */
  73365. disposeEffects(camera: Camera): void;
  73366. /**
  73367. * @hidden Internal
  73368. */
  73369. _updateEffects(): void;
  73370. /**
  73371. * Internal
  73372. * @returns if all the contained post processes are ready.
  73373. * @hidden
  73374. */
  73375. _isReady(): boolean;
  73376. }
  73377. }
  73378. declare module BABYLON {
  73379. /** @hidden */
  73380. export var chromaticAberrationPixelShader: {
  73381. name: string;
  73382. shader: string;
  73383. };
  73384. }
  73385. declare module BABYLON {
  73386. /**
  73387. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73388. */
  73389. export class ChromaticAberrationPostProcess extends PostProcess {
  73390. /**
  73391. * The amount of seperation of rgb channels (default: 30)
  73392. */
  73393. aberrationAmount: number;
  73394. /**
  73395. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73396. */
  73397. radialIntensity: number;
  73398. /**
  73399. * 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))
  73400. */
  73401. direction: Vector2;
  73402. /**
  73403. * 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))
  73404. */
  73405. centerPosition: Vector2;
  73406. /** The width of the screen to apply the effect on */
  73407. screenWidth: number;
  73408. /** The height of the screen to apply the effect on */
  73409. screenHeight: number;
  73410. /**
  73411. * Gets a string identifying the name of the class
  73412. * @returns "ChromaticAberrationPostProcess" string
  73413. */
  73414. getClassName(): string;
  73415. /**
  73416. * Creates a new instance ChromaticAberrationPostProcess
  73417. * @param name The name of the effect.
  73418. * @param screenWidth The width of the screen to apply the effect on.
  73419. * @param screenHeight The height of the screen to apply the effect on.
  73420. * @param options The required width/height ratio to downsize to before computing the render pass.
  73421. * @param camera The camera to apply the render pass to.
  73422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73423. * @param engine The engine which the post process will be applied. (default: current engine)
  73424. * @param reusable If the post process can be reused on the same frame. (default: false)
  73425. * @param textureType Type of textures used when performing the post process. (default: 0)
  73426. * @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)
  73427. */
  73428. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73429. /** @hidden */
  73430. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73431. }
  73432. }
  73433. declare module BABYLON {
  73434. /** @hidden */
  73435. export var circleOfConfusionPixelShader: {
  73436. name: string;
  73437. shader: string;
  73438. };
  73439. }
  73440. declare module BABYLON {
  73441. /**
  73442. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73443. */
  73444. export class CircleOfConfusionPostProcess extends PostProcess {
  73445. /**
  73446. * 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.
  73447. */
  73448. lensSize: number;
  73449. /**
  73450. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73451. */
  73452. fStop: number;
  73453. /**
  73454. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73455. */
  73456. focusDistance: number;
  73457. /**
  73458. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73459. */
  73460. focalLength: number;
  73461. /**
  73462. * Gets a string identifying the name of the class
  73463. * @returns "CircleOfConfusionPostProcess" string
  73464. */
  73465. getClassName(): string;
  73466. private _depthTexture;
  73467. /**
  73468. * Creates a new instance CircleOfConfusionPostProcess
  73469. * @param name The name of the effect.
  73470. * @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.
  73471. * @param options The required width/height ratio to downsize to before computing the render pass.
  73472. * @param camera The camera to apply the render pass to.
  73473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73474. * @param engine The engine which the post process will be applied. (default: current engine)
  73475. * @param reusable If the post process can be reused on the same frame. (default: false)
  73476. * @param textureType Type of textures used when performing the post process. (default: 0)
  73477. * @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)
  73478. */
  73479. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73480. /**
  73481. * 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.
  73482. */
  73483. set depthTexture(value: RenderTargetTexture);
  73484. }
  73485. }
  73486. declare module BABYLON {
  73487. /** @hidden */
  73488. export var colorCorrectionPixelShader: {
  73489. name: string;
  73490. shader: string;
  73491. };
  73492. }
  73493. declare module BABYLON {
  73494. /**
  73495. *
  73496. * This post-process allows the modification of rendered colors by using
  73497. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73498. *
  73499. * The object needs to be provided an url to a texture containing the color
  73500. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73501. * Use an image editing software to tweak the LUT to match your needs.
  73502. *
  73503. * For an example of a color LUT, see here:
  73504. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73505. * For explanations on color grading, see here:
  73506. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73507. *
  73508. */
  73509. export class ColorCorrectionPostProcess extends PostProcess {
  73510. private _colorTableTexture;
  73511. /**
  73512. * Gets the color table url used to create the LUT texture
  73513. */
  73514. colorTableUrl: string;
  73515. /**
  73516. * Gets a string identifying the name of the class
  73517. * @returns "ColorCorrectionPostProcess" string
  73518. */
  73519. getClassName(): string;
  73520. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73521. /** @hidden */
  73522. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73523. }
  73524. }
  73525. declare module BABYLON {
  73526. /** @hidden */
  73527. export var convolutionPixelShader: {
  73528. name: string;
  73529. shader: string;
  73530. };
  73531. }
  73532. declare module BABYLON {
  73533. /**
  73534. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73535. * input texture to perform effects such as edge detection or sharpening
  73536. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73537. */
  73538. export class ConvolutionPostProcess extends PostProcess {
  73539. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73540. kernel: number[];
  73541. /**
  73542. * Gets a string identifying the name of the class
  73543. * @returns "ConvolutionPostProcess" string
  73544. */
  73545. getClassName(): string;
  73546. /**
  73547. * Creates a new instance ConvolutionPostProcess
  73548. * @param name The name of the effect.
  73549. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73550. * @param options The required width/height ratio to downsize to before computing the render pass.
  73551. * @param camera The camera to apply the render pass to.
  73552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73553. * @param engine The engine which the post process will be applied. (default: current engine)
  73554. * @param reusable If the post process can be reused on the same frame. (default: false)
  73555. * @param textureType Type of textures used when performing the post process. (default: 0)
  73556. */
  73557. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73558. /** @hidden */
  73559. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73560. /**
  73561. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73562. */
  73563. static EdgeDetect0Kernel: number[];
  73564. /**
  73565. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73566. */
  73567. static EdgeDetect1Kernel: number[];
  73568. /**
  73569. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73570. */
  73571. static EdgeDetect2Kernel: number[];
  73572. /**
  73573. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73574. */
  73575. static SharpenKernel: number[];
  73576. /**
  73577. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73578. */
  73579. static EmbossKernel: number[];
  73580. /**
  73581. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73582. */
  73583. static GaussianKernel: number[];
  73584. }
  73585. }
  73586. declare module BABYLON {
  73587. /**
  73588. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73589. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73590. * based on samples that have a large difference in distance than the center pixel.
  73591. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73592. */
  73593. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73594. /**
  73595. * The direction the blur should be applied
  73596. */
  73597. direction: Vector2;
  73598. /**
  73599. * Gets a string identifying the name of the class
  73600. * @returns "DepthOfFieldBlurPostProcess" string
  73601. */
  73602. getClassName(): string;
  73603. /**
  73604. * Creates a new instance CircleOfConfusionPostProcess
  73605. * @param name The name of the effect.
  73606. * @param scene The scene the effect belongs to.
  73607. * @param direction The direction the blur should be applied.
  73608. * @param kernel The size of the kernel used to blur.
  73609. * @param options The required width/height ratio to downsize to before computing the render pass.
  73610. * @param camera The camera to apply the render pass to.
  73611. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73612. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73614. * @param engine The engine which the post process will be applied. (default: current engine)
  73615. * @param reusable If the post process can be reused on the same frame. (default: false)
  73616. * @param textureType Type of textures used when performing the post process. (default: 0)
  73617. * @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)
  73618. */
  73619. 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);
  73620. }
  73621. }
  73622. declare module BABYLON {
  73623. /** @hidden */
  73624. export var depthOfFieldMergePixelShader: {
  73625. name: string;
  73626. shader: string;
  73627. };
  73628. }
  73629. declare module BABYLON {
  73630. /**
  73631. * Options to be set when merging outputs from the default pipeline.
  73632. */
  73633. export class DepthOfFieldMergePostProcessOptions {
  73634. /**
  73635. * The original image to merge on top of
  73636. */
  73637. originalFromInput: PostProcess;
  73638. /**
  73639. * Parameters to perform the merge of the depth of field effect
  73640. */
  73641. depthOfField?: {
  73642. circleOfConfusion: PostProcess;
  73643. blurSteps: Array<PostProcess>;
  73644. };
  73645. /**
  73646. * Parameters to perform the merge of bloom effect
  73647. */
  73648. bloom?: {
  73649. blurred: PostProcess;
  73650. weight: number;
  73651. };
  73652. }
  73653. /**
  73654. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73655. */
  73656. export class DepthOfFieldMergePostProcess extends PostProcess {
  73657. private blurSteps;
  73658. /**
  73659. * Gets a string identifying the name of the class
  73660. * @returns "DepthOfFieldMergePostProcess" string
  73661. */
  73662. getClassName(): string;
  73663. /**
  73664. * Creates a new instance of DepthOfFieldMergePostProcess
  73665. * @param name The name of the effect.
  73666. * @param originalFromInput Post process which's input will be used for the merge.
  73667. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73668. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73669. * @param options The required width/height ratio to downsize to before computing the render pass.
  73670. * @param camera The camera to apply the render pass to.
  73671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73672. * @param engine The engine which the post process will be applied. (default: current engine)
  73673. * @param reusable If the post process can be reused on the same frame. (default: false)
  73674. * @param textureType Type of textures used when performing the post process. (default: 0)
  73675. * @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)
  73676. */
  73677. 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);
  73678. /**
  73679. * Updates the effect with the current post process compile time values and recompiles the shader.
  73680. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73681. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73682. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73683. * @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
  73684. * @param onCompiled Called when the shader has been compiled.
  73685. * @param onError Called if there is an error when compiling a shader.
  73686. */
  73687. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73688. }
  73689. }
  73690. declare module BABYLON {
  73691. /**
  73692. * Specifies the level of max blur that should be applied when using the depth of field effect
  73693. */
  73694. export enum DepthOfFieldEffectBlurLevel {
  73695. /**
  73696. * Subtle blur
  73697. */
  73698. Low = 0,
  73699. /**
  73700. * Medium blur
  73701. */
  73702. Medium = 1,
  73703. /**
  73704. * Large blur
  73705. */
  73706. High = 2
  73707. }
  73708. /**
  73709. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73710. */
  73711. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73712. private _circleOfConfusion;
  73713. /**
  73714. * @hidden Internal, blurs from high to low
  73715. */
  73716. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73717. private _depthOfFieldBlurY;
  73718. private _dofMerge;
  73719. /**
  73720. * @hidden Internal post processes in depth of field effect
  73721. */
  73722. _effects: Array<PostProcess>;
  73723. /**
  73724. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73725. */
  73726. set focalLength(value: number);
  73727. get focalLength(): number;
  73728. /**
  73729. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73730. */
  73731. set fStop(value: number);
  73732. get fStop(): number;
  73733. /**
  73734. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73735. */
  73736. set focusDistance(value: number);
  73737. get focusDistance(): number;
  73738. /**
  73739. * 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.
  73740. */
  73741. set lensSize(value: number);
  73742. get lensSize(): number;
  73743. /**
  73744. * Creates a new instance DepthOfFieldEffect
  73745. * @param scene The scene the effect belongs to.
  73746. * @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.
  73747. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73748. * @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)
  73749. */
  73750. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73751. /**
  73752. * Get the current class name of the current effet
  73753. * @returns "DepthOfFieldEffect"
  73754. */
  73755. getClassName(): string;
  73756. /**
  73757. * 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.
  73758. */
  73759. set depthTexture(value: RenderTargetTexture);
  73760. /**
  73761. * Disposes each of the internal effects for a given camera.
  73762. * @param camera The camera to dispose the effect on.
  73763. */
  73764. disposeEffects(camera: Camera): void;
  73765. /**
  73766. * @hidden Internal
  73767. */
  73768. _updateEffects(): void;
  73769. /**
  73770. * Internal
  73771. * @returns if all the contained post processes are ready.
  73772. * @hidden
  73773. */
  73774. _isReady(): boolean;
  73775. }
  73776. }
  73777. declare module BABYLON {
  73778. /** @hidden */
  73779. export var displayPassPixelShader: {
  73780. name: string;
  73781. shader: string;
  73782. };
  73783. }
  73784. declare module BABYLON {
  73785. /**
  73786. * DisplayPassPostProcess which produces an output the same as it's input
  73787. */
  73788. export class DisplayPassPostProcess extends PostProcess {
  73789. /**
  73790. * Gets a string identifying the name of the class
  73791. * @returns "DisplayPassPostProcess" string
  73792. */
  73793. getClassName(): string;
  73794. /**
  73795. * Creates the DisplayPassPostProcess
  73796. * @param name The name of the effect.
  73797. * @param options The required width/height ratio to downsize to before computing the render pass.
  73798. * @param camera The camera to apply the render pass to.
  73799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73800. * @param engine The engine which the post process will be applied. (default: current engine)
  73801. * @param reusable If the post process can be reused on the same frame. (default: false)
  73802. */
  73803. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73804. /** @hidden */
  73805. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73806. }
  73807. }
  73808. declare module BABYLON {
  73809. /** @hidden */
  73810. export var filterPixelShader: {
  73811. name: string;
  73812. shader: string;
  73813. };
  73814. }
  73815. declare module BABYLON {
  73816. /**
  73817. * Applies a kernel filter to the image
  73818. */
  73819. export class FilterPostProcess extends PostProcess {
  73820. /** The matrix to be applied to the image */
  73821. kernelMatrix: Matrix;
  73822. /**
  73823. * Gets a string identifying the name of the class
  73824. * @returns "FilterPostProcess" string
  73825. */
  73826. getClassName(): string;
  73827. /**
  73828. *
  73829. * @param name The name of the effect.
  73830. * @param kernelMatrix The matrix to be applied to the image
  73831. * @param options The required width/height ratio to downsize to before computing the render pass.
  73832. * @param camera The camera to apply the render pass to.
  73833. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73834. * @param engine The engine which the post process will be applied. (default: current engine)
  73835. * @param reusable If the post process can be reused on the same frame. (default: false)
  73836. */
  73837. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73838. /** @hidden */
  73839. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73840. }
  73841. }
  73842. declare module BABYLON {
  73843. /** @hidden */
  73844. export var fxaaPixelShader: {
  73845. name: string;
  73846. shader: string;
  73847. };
  73848. }
  73849. declare module BABYLON {
  73850. /** @hidden */
  73851. export var fxaaVertexShader: {
  73852. name: string;
  73853. shader: string;
  73854. };
  73855. }
  73856. declare module BABYLON {
  73857. /**
  73858. * Fxaa post process
  73859. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73860. */
  73861. export class FxaaPostProcess extends PostProcess {
  73862. /**
  73863. * Gets a string identifying the name of the class
  73864. * @returns "FxaaPostProcess" string
  73865. */
  73866. getClassName(): string;
  73867. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73868. private _getDefines;
  73869. /** @hidden */
  73870. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73871. }
  73872. }
  73873. declare module BABYLON {
  73874. /** @hidden */
  73875. export var grainPixelShader: {
  73876. name: string;
  73877. shader: string;
  73878. };
  73879. }
  73880. declare module BABYLON {
  73881. /**
  73882. * The GrainPostProcess adds noise to the image at mid luminance levels
  73883. */
  73884. export class GrainPostProcess extends PostProcess {
  73885. /**
  73886. * The intensity of the grain added (default: 30)
  73887. */
  73888. intensity: number;
  73889. /**
  73890. * If the grain should be randomized on every frame
  73891. */
  73892. animated: boolean;
  73893. /**
  73894. * Gets a string identifying the name of the class
  73895. * @returns "GrainPostProcess" string
  73896. */
  73897. getClassName(): string;
  73898. /**
  73899. * Creates a new instance of @see GrainPostProcess
  73900. * @param name The name of the effect.
  73901. * @param options The required width/height ratio to downsize to before computing the render pass.
  73902. * @param camera The camera to apply the render pass to.
  73903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73904. * @param engine The engine which the post process will be applied. (default: current engine)
  73905. * @param reusable If the post process can be reused on the same frame. (default: false)
  73906. * @param textureType Type of textures used when performing the post process. (default: 0)
  73907. * @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)
  73908. */
  73909. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73910. /** @hidden */
  73911. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73912. }
  73913. }
  73914. declare module BABYLON {
  73915. /** @hidden */
  73916. export var highlightsPixelShader: {
  73917. name: string;
  73918. shader: string;
  73919. };
  73920. }
  73921. declare module BABYLON {
  73922. /**
  73923. * Extracts highlights from the image
  73924. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73925. */
  73926. export class HighlightsPostProcess extends PostProcess {
  73927. /**
  73928. * Gets a string identifying the name of the class
  73929. * @returns "HighlightsPostProcess" string
  73930. */
  73931. getClassName(): string;
  73932. /**
  73933. * Extracts highlights from the image
  73934. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73935. * @param name The name of the effect.
  73936. * @param options The required width/height ratio to downsize to before computing the render pass.
  73937. * @param camera The camera to apply the render pass to.
  73938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73939. * @param engine The engine which the post process will be applied. (default: current engine)
  73940. * @param reusable If the post process can be reused on the same frame. (default: false)
  73941. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73942. */
  73943. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73944. }
  73945. }
  73946. declare module BABYLON {
  73947. /**
  73948. * Contains all parameters needed for the prepass to perform
  73949. * motion blur
  73950. */
  73951. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  73952. /**
  73953. * Is motion blur enabled
  73954. */
  73955. enabled: boolean;
  73956. /**
  73957. * Name of the configuration
  73958. */
  73959. name: string;
  73960. /**
  73961. * Textures that should be present in the MRT for this effect to work
  73962. */
  73963. readonly texturesRequired: number[];
  73964. }
  73965. }
  73966. declare module BABYLON {
  73967. interface Scene {
  73968. /** @hidden (Backing field) */
  73969. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73970. /**
  73971. * Gets or Sets the current geometry buffer associated to the scene.
  73972. */
  73973. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73974. /**
  73975. * Enables a GeometryBufferRender and associates it with the scene
  73976. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73977. * @returns the GeometryBufferRenderer
  73978. */
  73979. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73980. /**
  73981. * Disables the GeometryBufferRender associated with the scene
  73982. */
  73983. disableGeometryBufferRenderer(): void;
  73984. }
  73985. /**
  73986. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73987. * in several rendering techniques.
  73988. */
  73989. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73990. /**
  73991. * The component name helpful to identify the component in the list of scene components.
  73992. */
  73993. readonly name: string;
  73994. /**
  73995. * The scene the component belongs to.
  73996. */
  73997. scene: Scene;
  73998. /**
  73999. * Creates a new instance of the component for the given scene
  74000. * @param scene Defines the scene to register the component in
  74001. */
  74002. constructor(scene: Scene);
  74003. /**
  74004. * Registers the component in a given scene
  74005. */
  74006. register(): void;
  74007. /**
  74008. * Rebuilds the elements related to this component in case of
  74009. * context lost for instance.
  74010. */
  74011. rebuild(): void;
  74012. /**
  74013. * Disposes the component and the associated ressources
  74014. */
  74015. dispose(): void;
  74016. private _gatherRenderTargets;
  74017. }
  74018. }
  74019. declare module BABYLON {
  74020. /** @hidden */
  74021. export var motionBlurPixelShader: {
  74022. name: string;
  74023. shader: string;
  74024. };
  74025. }
  74026. declare module BABYLON {
  74027. /**
  74028. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74029. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74030. * As an example, all you have to do is to create the post-process:
  74031. * var mb = new BABYLON.MotionBlurPostProcess(
  74032. * 'mb', // The name of the effect.
  74033. * scene, // The scene containing the objects to blur according to their velocity.
  74034. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74035. * camera // The camera to apply the render pass to.
  74036. * );
  74037. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74038. */
  74039. export class MotionBlurPostProcess extends PostProcess {
  74040. /**
  74041. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74042. */
  74043. motionStrength: number;
  74044. /**
  74045. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74046. */
  74047. get motionBlurSamples(): number;
  74048. /**
  74049. * Sets the number of iterations to be used for motion blur quality
  74050. */
  74051. set motionBlurSamples(samples: number);
  74052. private _motionBlurSamples;
  74053. /**
  74054. * Gets wether or not the motion blur post-process is in object based mode.
  74055. */
  74056. get isObjectBased(): boolean;
  74057. /**
  74058. * Sets wether or not the motion blur post-process is in object based mode.
  74059. */
  74060. set isObjectBased(value: boolean);
  74061. private _isObjectBased;
  74062. private _forceGeometryBuffer;
  74063. private _geometryBufferRenderer;
  74064. private _prePassRenderer;
  74065. private _invViewProjection;
  74066. private _previousViewProjection;
  74067. /**
  74068. * Gets a string identifying the name of the class
  74069. * @returns "MotionBlurPostProcess" string
  74070. */
  74071. getClassName(): string;
  74072. /**
  74073. * Creates a new instance MotionBlurPostProcess
  74074. * @param name The name of the effect.
  74075. * @param scene The scene containing the objects to blur according to their velocity.
  74076. * @param options The required width/height ratio to downsize to before computing the render pass.
  74077. * @param camera The camera to apply the render pass to.
  74078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74079. * @param engine The engine which the post process will be applied. (default: current engine)
  74080. * @param reusable If the post process can be reused on the same frame. (default: false)
  74081. * @param textureType Type of textures used when performing the post process. (default: 0)
  74082. * @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)
  74083. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74084. */
  74085. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74086. /**
  74087. * Excludes the given skinned mesh from computing bones velocities.
  74088. * 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.
  74089. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74090. */
  74091. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74092. /**
  74093. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74094. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74095. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74096. */
  74097. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74098. /**
  74099. * Disposes the post process.
  74100. * @param camera The camera to dispose the post process on.
  74101. */
  74102. dispose(camera?: Camera): void;
  74103. /**
  74104. * Called on the mode changed (object based or screen based).
  74105. */
  74106. private _applyMode;
  74107. /**
  74108. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74109. */
  74110. private _onApplyObjectBased;
  74111. /**
  74112. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74113. */
  74114. private _onApplyScreenBased;
  74115. /**
  74116. * Called on the effect must be updated (changed mode, samples count, etc.).
  74117. */
  74118. private _updateEffect;
  74119. /** @hidden */
  74120. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74121. }
  74122. }
  74123. declare module BABYLON {
  74124. /** @hidden */
  74125. export var refractionPixelShader: {
  74126. name: string;
  74127. shader: string;
  74128. };
  74129. }
  74130. declare module BABYLON {
  74131. /**
  74132. * Post process which applies a refractin texture
  74133. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74134. */
  74135. export class RefractionPostProcess extends PostProcess {
  74136. private _refTexture;
  74137. private _ownRefractionTexture;
  74138. /** the base color of the refraction (used to taint the rendering) */
  74139. color: Color3;
  74140. /** simulated refraction depth */
  74141. depth: number;
  74142. /** the coefficient of the base color (0 to remove base color tainting) */
  74143. colorLevel: number;
  74144. /** Gets the url used to load the refraction texture */
  74145. refractionTextureUrl: string;
  74146. /**
  74147. * Gets or sets the refraction texture
  74148. * Please note that you are responsible for disposing the texture if you set it manually
  74149. */
  74150. get refractionTexture(): Texture;
  74151. set refractionTexture(value: Texture);
  74152. /**
  74153. * Gets a string identifying the name of the class
  74154. * @returns "RefractionPostProcess" string
  74155. */
  74156. getClassName(): string;
  74157. /**
  74158. * Initializes the RefractionPostProcess
  74159. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74160. * @param name The name of the effect.
  74161. * @param refractionTextureUrl Url of the refraction texture to use
  74162. * @param color the base color of the refraction (used to taint the rendering)
  74163. * @param depth simulated refraction depth
  74164. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74165. * @param camera The camera to apply the render pass to.
  74166. * @param options The required width/height ratio to downsize to before computing the render pass.
  74167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74168. * @param engine The engine which the post process will be applied. (default: current engine)
  74169. * @param reusable If the post process can be reused on the same frame. (default: false)
  74170. */
  74171. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74172. /**
  74173. * Disposes of the post process
  74174. * @param camera Camera to dispose post process on
  74175. */
  74176. dispose(camera: Camera): void;
  74177. /** @hidden */
  74178. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74179. }
  74180. }
  74181. declare module BABYLON {
  74182. /** @hidden */
  74183. export var sharpenPixelShader: {
  74184. name: string;
  74185. shader: string;
  74186. };
  74187. }
  74188. declare module BABYLON {
  74189. /**
  74190. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74191. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74192. */
  74193. export class SharpenPostProcess extends PostProcess {
  74194. /**
  74195. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74196. */
  74197. colorAmount: number;
  74198. /**
  74199. * How much sharpness should be applied (default: 0.3)
  74200. */
  74201. edgeAmount: number;
  74202. /**
  74203. * Gets a string identifying the name of the class
  74204. * @returns "SharpenPostProcess" string
  74205. */
  74206. getClassName(): string;
  74207. /**
  74208. * Creates a new instance ConvolutionPostProcess
  74209. * @param name The name of the effect.
  74210. * @param options The required width/height ratio to downsize to before computing the render pass.
  74211. * @param camera The camera to apply the render pass to.
  74212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74213. * @param engine The engine which the post process will be applied. (default: current engine)
  74214. * @param reusable If the post process can be reused on the same frame. (default: false)
  74215. * @param textureType Type of textures used when performing the post process. (default: 0)
  74216. * @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)
  74217. */
  74218. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74219. /** @hidden */
  74220. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74221. }
  74222. }
  74223. declare module BABYLON {
  74224. /**
  74225. * PostProcessRenderPipeline
  74226. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74227. */
  74228. export class PostProcessRenderPipeline {
  74229. private engine;
  74230. private _renderEffects;
  74231. private _renderEffectsForIsolatedPass;
  74232. /**
  74233. * List of inspectable custom properties (used by the Inspector)
  74234. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74235. */
  74236. inspectableCustomProperties: IInspectable[];
  74237. /**
  74238. * @hidden
  74239. */
  74240. protected _cameras: Camera[];
  74241. /** @hidden */
  74242. _name: string;
  74243. /**
  74244. * Gets pipeline name
  74245. */
  74246. get name(): string;
  74247. /** Gets the list of attached cameras */
  74248. get cameras(): Camera[];
  74249. /**
  74250. * Initializes a PostProcessRenderPipeline
  74251. * @param engine engine to add the pipeline to
  74252. * @param name name of the pipeline
  74253. */
  74254. constructor(engine: Engine, name: string);
  74255. /**
  74256. * Gets the class name
  74257. * @returns "PostProcessRenderPipeline"
  74258. */
  74259. getClassName(): string;
  74260. /**
  74261. * If all the render effects in the pipeline are supported
  74262. */
  74263. get isSupported(): boolean;
  74264. /**
  74265. * Adds an effect to the pipeline
  74266. * @param renderEffect the effect to add
  74267. */
  74268. addEffect(renderEffect: PostProcessRenderEffect): void;
  74269. /** @hidden */
  74270. _rebuild(): void;
  74271. /** @hidden */
  74272. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74273. /** @hidden */
  74274. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74275. /** @hidden */
  74276. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74277. /** @hidden */
  74278. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74279. /** @hidden */
  74280. _attachCameras(cameras: Camera, unique: boolean): void;
  74281. /** @hidden */
  74282. _attachCameras(cameras: Camera[], unique: boolean): void;
  74283. /** @hidden */
  74284. _detachCameras(cameras: Camera): void;
  74285. /** @hidden */
  74286. _detachCameras(cameras: Nullable<Camera[]>): void;
  74287. /** @hidden */
  74288. _update(): void;
  74289. /** @hidden */
  74290. _reset(): void;
  74291. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74292. /**
  74293. * Sets the required values to the prepass renderer.
  74294. * @param prePassRenderer defines the prepass renderer to setup.
  74295. * @returns true if the pre pass is needed.
  74296. */
  74297. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74298. /**
  74299. * Disposes of the pipeline
  74300. */
  74301. dispose(): void;
  74302. }
  74303. }
  74304. declare module BABYLON {
  74305. /**
  74306. * PostProcessRenderPipelineManager class
  74307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74308. */
  74309. export class PostProcessRenderPipelineManager {
  74310. private _renderPipelines;
  74311. /**
  74312. * Initializes a PostProcessRenderPipelineManager
  74313. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74314. */
  74315. constructor();
  74316. /**
  74317. * Gets the list of supported render pipelines
  74318. */
  74319. get supportedPipelines(): PostProcessRenderPipeline[];
  74320. /**
  74321. * Adds a pipeline to the manager
  74322. * @param renderPipeline The pipeline to add
  74323. */
  74324. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74325. /**
  74326. * Attaches a camera to the pipeline
  74327. * @param renderPipelineName The name of the pipeline to attach to
  74328. * @param cameras the camera to attach
  74329. * @param unique if the camera can be attached multiple times to the pipeline
  74330. */
  74331. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74332. /**
  74333. * Detaches a camera from the pipeline
  74334. * @param renderPipelineName The name of the pipeline to detach from
  74335. * @param cameras the camera to detach
  74336. */
  74337. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74338. /**
  74339. * Enables an effect by name on a pipeline
  74340. * @param renderPipelineName the name of the pipeline to enable the effect in
  74341. * @param renderEffectName the name of the effect to enable
  74342. * @param cameras the cameras that the effect should be enabled on
  74343. */
  74344. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74345. /**
  74346. * Disables an effect by name on a pipeline
  74347. * @param renderPipelineName the name of the pipeline to disable the effect in
  74348. * @param renderEffectName the name of the effect to disable
  74349. * @param cameras the cameras that the effect should be disabled on
  74350. */
  74351. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74352. /**
  74353. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74354. */
  74355. update(): void;
  74356. /** @hidden */
  74357. _rebuild(): void;
  74358. /**
  74359. * Disposes of the manager and pipelines
  74360. */
  74361. dispose(): void;
  74362. }
  74363. }
  74364. declare module BABYLON {
  74365. interface Scene {
  74366. /** @hidden (Backing field) */
  74367. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74368. /**
  74369. * Gets the postprocess render pipeline manager
  74370. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74371. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74372. */
  74373. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74374. }
  74375. /**
  74376. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74377. */
  74378. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74379. /**
  74380. * The component name helpfull to identify the component in the list of scene components.
  74381. */
  74382. readonly name: string;
  74383. /**
  74384. * The scene the component belongs to.
  74385. */
  74386. scene: Scene;
  74387. /**
  74388. * Creates a new instance of the component for the given scene
  74389. * @param scene Defines the scene to register the component in
  74390. */
  74391. constructor(scene: Scene);
  74392. /**
  74393. * Registers the component in a given scene
  74394. */
  74395. register(): void;
  74396. /**
  74397. * Rebuilds the elements related to this component in case of
  74398. * context lost for instance.
  74399. */
  74400. rebuild(): void;
  74401. /**
  74402. * Disposes the component and the associated ressources
  74403. */
  74404. dispose(): void;
  74405. private _gatherRenderTargets;
  74406. }
  74407. }
  74408. declare module BABYLON {
  74409. /**
  74410. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74411. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74412. */
  74413. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74414. private _scene;
  74415. private _camerasToBeAttached;
  74416. /**
  74417. * ID of the sharpen post process,
  74418. */
  74419. private readonly SharpenPostProcessId;
  74420. /**
  74421. * @ignore
  74422. * ID of the image processing post process;
  74423. */
  74424. readonly ImageProcessingPostProcessId: string;
  74425. /**
  74426. * @ignore
  74427. * ID of the Fast Approximate Anti-Aliasing post process;
  74428. */
  74429. readonly FxaaPostProcessId: string;
  74430. /**
  74431. * ID of the chromatic aberration post process,
  74432. */
  74433. private readonly ChromaticAberrationPostProcessId;
  74434. /**
  74435. * ID of the grain post process
  74436. */
  74437. private readonly GrainPostProcessId;
  74438. /**
  74439. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74440. */
  74441. sharpen: SharpenPostProcess;
  74442. private _sharpenEffect;
  74443. private bloom;
  74444. /**
  74445. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74446. */
  74447. depthOfField: DepthOfFieldEffect;
  74448. /**
  74449. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74450. */
  74451. fxaa: FxaaPostProcess;
  74452. /**
  74453. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74454. */
  74455. imageProcessing: ImageProcessingPostProcess;
  74456. /**
  74457. * Chromatic aberration post process which will shift rgb colors in the image
  74458. */
  74459. chromaticAberration: ChromaticAberrationPostProcess;
  74460. private _chromaticAberrationEffect;
  74461. /**
  74462. * Grain post process which add noise to the image
  74463. */
  74464. grain: GrainPostProcess;
  74465. private _grainEffect;
  74466. /**
  74467. * Glow post process which adds a glow to emissive areas of the image
  74468. */
  74469. private _glowLayer;
  74470. /**
  74471. * Animations which can be used to tweak settings over a period of time
  74472. */
  74473. animations: Animation[];
  74474. private _imageProcessingConfigurationObserver;
  74475. private _sharpenEnabled;
  74476. private _bloomEnabled;
  74477. private _depthOfFieldEnabled;
  74478. private _depthOfFieldBlurLevel;
  74479. private _fxaaEnabled;
  74480. private _imageProcessingEnabled;
  74481. private _defaultPipelineTextureType;
  74482. private _bloomScale;
  74483. private _chromaticAberrationEnabled;
  74484. private _grainEnabled;
  74485. private _buildAllowed;
  74486. /**
  74487. * This is triggered each time the pipeline has been built.
  74488. */
  74489. onBuildObservable: Observable<DefaultRenderingPipeline>;
  74490. /**
  74491. * Gets active scene
  74492. */
  74493. get scene(): Scene;
  74494. /**
  74495. * Enable or disable the sharpen process from the pipeline
  74496. */
  74497. set sharpenEnabled(enabled: boolean);
  74498. get sharpenEnabled(): boolean;
  74499. private _resizeObserver;
  74500. private _hardwareScaleLevel;
  74501. private _bloomKernel;
  74502. /**
  74503. * Specifies the size of the bloom blur kernel, relative to the final output size
  74504. */
  74505. get bloomKernel(): number;
  74506. set bloomKernel(value: number);
  74507. /**
  74508. * Specifies the weight of the bloom in the final rendering
  74509. */
  74510. private _bloomWeight;
  74511. /**
  74512. * Specifies the luma threshold for the area that will be blurred by the bloom
  74513. */
  74514. private _bloomThreshold;
  74515. private _hdr;
  74516. /**
  74517. * The strength of the bloom.
  74518. */
  74519. set bloomWeight(value: number);
  74520. get bloomWeight(): number;
  74521. /**
  74522. * The strength of the bloom.
  74523. */
  74524. set bloomThreshold(value: number);
  74525. get bloomThreshold(): number;
  74526. /**
  74527. * The scale of the bloom, lower value will provide better performance.
  74528. */
  74529. set bloomScale(value: number);
  74530. get bloomScale(): number;
  74531. /**
  74532. * Enable or disable the bloom from the pipeline
  74533. */
  74534. set bloomEnabled(enabled: boolean);
  74535. get bloomEnabled(): boolean;
  74536. private _rebuildBloom;
  74537. /**
  74538. * If the depth of field is enabled.
  74539. */
  74540. get depthOfFieldEnabled(): boolean;
  74541. set depthOfFieldEnabled(enabled: boolean);
  74542. /**
  74543. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74544. */
  74545. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74546. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74547. /**
  74548. * If the anti aliasing is enabled.
  74549. */
  74550. set fxaaEnabled(enabled: boolean);
  74551. get fxaaEnabled(): boolean;
  74552. private _samples;
  74553. /**
  74554. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74555. */
  74556. set samples(sampleCount: number);
  74557. get samples(): number;
  74558. /**
  74559. * If image processing is enabled.
  74560. */
  74561. set imageProcessingEnabled(enabled: boolean);
  74562. get imageProcessingEnabled(): boolean;
  74563. /**
  74564. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74565. */
  74566. set glowLayerEnabled(enabled: boolean);
  74567. get glowLayerEnabled(): boolean;
  74568. /**
  74569. * Gets the glow layer (or null if not defined)
  74570. */
  74571. get glowLayer(): Nullable<GlowLayer>;
  74572. /**
  74573. * Enable or disable the chromaticAberration process from the pipeline
  74574. */
  74575. set chromaticAberrationEnabled(enabled: boolean);
  74576. get chromaticAberrationEnabled(): boolean;
  74577. /**
  74578. * Enable or disable the grain process from the pipeline
  74579. */
  74580. set grainEnabled(enabled: boolean);
  74581. get grainEnabled(): boolean;
  74582. /**
  74583. * @constructor
  74584. * @param name - The rendering pipeline name (default: "")
  74585. * @param hdr - If high dynamic range textures should be used (default: true)
  74586. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74587. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74588. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74589. */
  74590. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74591. /**
  74592. * Get the class name
  74593. * @returns "DefaultRenderingPipeline"
  74594. */
  74595. getClassName(): string;
  74596. /**
  74597. * Force the compilation of the entire pipeline.
  74598. */
  74599. prepare(): void;
  74600. private _hasCleared;
  74601. private _prevPostProcess;
  74602. private _prevPrevPostProcess;
  74603. private _setAutoClearAndTextureSharing;
  74604. private _depthOfFieldSceneObserver;
  74605. private _buildPipeline;
  74606. private _disposePostProcesses;
  74607. /**
  74608. * Adds a camera to the pipeline
  74609. * @param camera the camera to be added
  74610. */
  74611. addCamera(camera: Camera): void;
  74612. /**
  74613. * Removes a camera from the pipeline
  74614. * @param camera the camera to remove
  74615. */
  74616. removeCamera(camera: Camera): void;
  74617. /**
  74618. * Dispose of the pipeline and stop all post processes
  74619. */
  74620. dispose(): void;
  74621. /**
  74622. * Serialize the rendering pipeline (Used when exporting)
  74623. * @returns the serialized object
  74624. */
  74625. serialize(): any;
  74626. /**
  74627. * Parse the serialized pipeline
  74628. * @param source Source pipeline.
  74629. * @param scene The scene to load the pipeline to.
  74630. * @param rootUrl The URL of the serialized pipeline.
  74631. * @returns An instantiated pipeline from the serialized object.
  74632. */
  74633. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74634. }
  74635. }
  74636. declare module BABYLON {
  74637. /** @hidden */
  74638. export var lensHighlightsPixelShader: {
  74639. name: string;
  74640. shader: string;
  74641. };
  74642. }
  74643. declare module BABYLON {
  74644. /** @hidden */
  74645. export var depthOfFieldPixelShader: {
  74646. name: string;
  74647. shader: string;
  74648. };
  74649. }
  74650. declare module BABYLON {
  74651. /**
  74652. * BABYLON.JS Chromatic Aberration GLSL Shader
  74653. * Author: Olivier Guyot
  74654. * Separates very slightly R, G and B colors on the edges of the screen
  74655. * Inspired by Francois Tarlier & Martins Upitis
  74656. */
  74657. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74658. /**
  74659. * @ignore
  74660. * The chromatic aberration PostProcess id in the pipeline
  74661. */
  74662. LensChromaticAberrationEffect: string;
  74663. /**
  74664. * @ignore
  74665. * The highlights enhancing PostProcess id in the pipeline
  74666. */
  74667. HighlightsEnhancingEffect: string;
  74668. /**
  74669. * @ignore
  74670. * The depth-of-field PostProcess id in the pipeline
  74671. */
  74672. LensDepthOfFieldEffect: string;
  74673. private _scene;
  74674. private _depthTexture;
  74675. private _grainTexture;
  74676. private _chromaticAberrationPostProcess;
  74677. private _highlightsPostProcess;
  74678. private _depthOfFieldPostProcess;
  74679. private _edgeBlur;
  74680. private _grainAmount;
  74681. private _chromaticAberration;
  74682. private _distortion;
  74683. private _highlightsGain;
  74684. private _highlightsThreshold;
  74685. private _dofDistance;
  74686. private _dofAperture;
  74687. private _dofDarken;
  74688. private _dofPentagon;
  74689. private _blurNoise;
  74690. /**
  74691. * @constructor
  74692. *
  74693. * Effect parameters are as follow:
  74694. * {
  74695. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74696. * edge_blur: number; // from 0 to x (1 for realism)
  74697. * distortion: number; // from 0 to x (1 for realism)
  74698. * grain_amount: number; // from 0 to 1
  74699. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74700. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74701. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74702. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74703. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74704. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74705. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74706. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74707. * }
  74708. * Note: if an effect parameter is unset, effect is disabled
  74709. *
  74710. * @param name The rendering pipeline name
  74711. * @param parameters - An object containing all parameters (see above)
  74712. * @param scene The scene linked to this pipeline
  74713. * @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)
  74714. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74715. */
  74716. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74717. /**
  74718. * Get the class name
  74719. * @returns "LensRenderingPipeline"
  74720. */
  74721. getClassName(): string;
  74722. /**
  74723. * Gets associated scene
  74724. */
  74725. get scene(): Scene;
  74726. /**
  74727. * Gets or sets the edge blur
  74728. */
  74729. get edgeBlur(): number;
  74730. set edgeBlur(value: number);
  74731. /**
  74732. * Gets or sets the grain amount
  74733. */
  74734. get grainAmount(): number;
  74735. set grainAmount(value: number);
  74736. /**
  74737. * Gets or sets the chromatic aberration amount
  74738. */
  74739. get chromaticAberration(): number;
  74740. set chromaticAberration(value: number);
  74741. /**
  74742. * Gets or sets the depth of field aperture
  74743. */
  74744. get dofAperture(): number;
  74745. set dofAperture(value: number);
  74746. /**
  74747. * Gets or sets the edge distortion
  74748. */
  74749. get edgeDistortion(): number;
  74750. set edgeDistortion(value: number);
  74751. /**
  74752. * Gets or sets the depth of field distortion
  74753. */
  74754. get dofDistortion(): number;
  74755. set dofDistortion(value: number);
  74756. /**
  74757. * Gets or sets the darken out of focus amount
  74758. */
  74759. get darkenOutOfFocus(): number;
  74760. set darkenOutOfFocus(value: number);
  74761. /**
  74762. * Gets or sets a boolean indicating if blur noise is enabled
  74763. */
  74764. get blurNoise(): boolean;
  74765. set blurNoise(value: boolean);
  74766. /**
  74767. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74768. */
  74769. get pentagonBokeh(): boolean;
  74770. set pentagonBokeh(value: boolean);
  74771. /**
  74772. * Gets or sets the highlight grain amount
  74773. */
  74774. get highlightsGain(): number;
  74775. set highlightsGain(value: number);
  74776. /**
  74777. * Gets or sets the highlight threshold
  74778. */
  74779. get highlightsThreshold(): number;
  74780. set highlightsThreshold(value: number);
  74781. /**
  74782. * Sets the amount of blur at the edges
  74783. * @param amount blur amount
  74784. */
  74785. setEdgeBlur(amount: number): void;
  74786. /**
  74787. * Sets edge blur to 0
  74788. */
  74789. disableEdgeBlur(): void;
  74790. /**
  74791. * Sets the amout of grain
  74792. * @param amount Amount of grain
  74793. */
  74794. setGrainAmount(amount: number): void;
  74795. /**
  74796. * Set grain amount to 0
  74797. */
  74798. disableGrain(): void;
  74799. /**
  74800. * Sets the chromatic aberration amount
  74801. * @param amount amount of chromatic aberration
  74802. */
  74803. setChromaticAberration(amount: number): void;
  74804. /**
  74805. * Sets chromatic aberration amount to 0
  74806. */
  74807. disableChromaticAberration(): void;
  74808. /**
  74809. * Sets the EdgeDistortion amount
  74810. * @param amount amount of EdgeDistortion
  74811. */
  74812. setEdgeDistortion(amount: number): void;
  74813. /**
  74814. * Sets edge distortion to 0
  74815. */
  74816. disableEdgeDistortion(): void;
  74817. /**
  74818. * Sets the FocusDistance amount
  74819. * @param amount amount of FocusDistance
  74820. */
  74821. setFocusDistance(amount: number): void;
  74822. /**
  74823. * Disables depth of field
  74824. */
  74825. disableDepthOfField(): void;
  74826. /**
  74827. * Sets the Aperture amount
  74828. * @param amount amount of Aperture
  74829. */
  74830. setAperture(amount: number): void;
  74831. /**
  74832. * Sets the DarkenOutOfFocus amount
  74833. * @param amount amount of DarkenOutOfFocus
  74834. */
  74835. setDarkenOutOfFocus(amount: number): void;
  74836. private _pentagonBokehIsEnabled;
  74837. /**
  74838. * Creates a pentagon bokeh effect
  74839. */
  74840. enablePentagonBokeh(): void;
  74841. /**
  74842. * Disables the pentagon bokeh effect
  74843. */
  74844. disablePentagonBokeh(): void;
  74845. /**
  74846. * Enables noise blur
  74847. */
  74848. enableNoiseBlur(): void;
  74849. /**
  74850. * Disables noise blur
  74851. */
  74852. disableNoiseBlur(): void;
  74853. /**
  74854. * Sets the HighlightsGain amount
  74855. * @param amount amount of HighlightsGain
  74856. */
  74857. setHighlightsGain(amount: number): void;
  74858. /**
  74859. * Sets the HighlightsThreshold amount
  74860. * @param amount amount of HighlightsThreshold
  74861. */
  74862. setHighlightsThreshold(amount: number): void;
  74863. /**
  74864. * Disables highlights
  74865. */
  74866. disableHighlights(): void;
  74867. /**
  74868. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74869. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74870. */
  74871. dispose(disableDepthRender?: boolean): void;
  74872. private _createChromaticAberrationPostProcess;
  74873. private _createHighlightsPostProcess;
  74874. private _createDepthOfFieldPostProcess;
  74875. private _createGrainTexture;
  74876. }
  74877. }
  74878. declare module BABYLON {
  74879. /**
  74880. * Contains all parameters needed for the prepass to perform
  74881. * screen space subsurface scattering
  74882. */
  74883. export class SSAO2Configuration implements PrePassEffectConfiguration {
  74884. /**
  74885. * Is subsurface enabled
  74886. */
  74887. enabled: boolean;
  74888. /**
  74889. * Name of the configuration
  74890. */
  74891. name: string;
  74892. /**
  74893. * Textures that should be present in the MRT for this effect to work
  74894. */
  74895. readonly texturesRequired: number[];
  74896. }
  74897. }
  74898. declare module BABYLON {
  74899. /** @hidden */
  74900. export var ssao2PixelShader: {
  74901. name: string;
  74902. shader: string;
  74903. };
  74904. }
  74905. declare module BABYLON {
  74906. /** @hidden */
  74907. export var ssaoCombinePixelShader: {
  74908. name: string;
  74909. shader: string;
  74910. };
  74911. }
  74912. declare module BABYLON {
  74913. /**
  74914. * Render pipeline to produce ssao effect
  74915. */
  74916. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74917. /**
  74918. * @ignore
  74919. * The PassPostProcess id in the pipeline that contains the original scene color
  74920. */
  74921. SSAOOriginalSceneColorEffect: string;
  74922. /**
  74923. * @ignore
  74924. * The SSAO PostProcess id in the pipeline
  74925. */
  74926. SSAORenderEffect: string;
  74927. /**
  74928. * @ignore
  74929. * The horizontal blur PostProcess id in the pipeline
  74930. */
  74931. SSAOBlurHRenderEffect: string;
  74932. /**
  74933. * @ignore
  74934. * The vertical blur PostProcess id in the pipeline
  74935. */
  74936. SSAOBlurVRenderEffect: string;
  74937. /**
  74938. * @ignore
  74939. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74940. */
  74941. SSAOCombineRenderEffect: string;
  74942. /**
  74943. * The output strength of the SSAO post-process. Default value is 1.0.
  74944. */
  74945. totalStrength: number;
  74946. /**
  74947. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74948. */
  74949. maxZ: number;
  74950. /**
  74951. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74952. */
  74953. minZAspect: number;
  74954. private _samples;
  74955. /**
  74956. * Number of samples used for the SSAO calculations. Default value is 8
  74957. */
  74958. set samples(n: number);
  74959. get samples(): number;
  74960. private _textureSamples;
  74961. /**
  74962. * Number of samples to use for antialiasing
  74963. */
  74964. set textureSamples(n: number);
  74965. get textureSamples(): number;
  74966. /**
  74967. * Force rendering the geometry through geometry buffer
  74968. */
  74969. private _forceGeometryBuffer;
  74970. /**
  74971. * Ratio object used for SSAO ratio and blur ratio
  74972. */
  74973. private _ratio;
  74974. /**
  74975. * Dynamically generated sphere sampler.
  74976. */
  74977. private _sampleSphere;
  74978. /**
  74979. * Blur filter offsets
  74980. */
  74981. private _samplerOffsets;
  74982. private _expensiveBlur;
  74983. /**
  74984. * If bilateral blur should be used
  74985. */
  74986. set expensiveBlur(b: boolean);
  74987. get expensiveBlur(): boolean;
  74988. /**
  74989. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74990. */
  74991. radius: number;
  74992. /**
  74993. * The base color of the SSAO post-process
  74994. * The final result is "base + ssao" between [0, 1]
  74995. */
  74996. base: number;
  74997. /**
  74998. * Support test.
  74999. */
  75000. static get IsSupported(): boolean;
  75001. private _scene;
  75002. private _randomTexture;
  75003. private _originalColorPostProcess;
  75004. private _ssaoPostProcess;
  75005. private _blurHPostProcess;
  75006. private _blurVPostProcess;
  75007. private _ssaoCombinePostProcess;
  75008. private _prePassRenderer;
  75009. /**
  75010. * Gets active scene
  75011. */
  75012. get scene(): Scene;
  75013. /**
  75014. * @constructor
  75015. * @param name The rendering pipeline name
  75016. * @param scene The scene linked to this pipeline
  75017. * @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 }
  75018. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75019. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75020. */
  75021. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75022. /**
  75023. * Get the class name
  75024. * @returns "SSAO2RenderingPipeline"
  75025. */
  75026. getClassName(): string;
  75027. /**
  75028. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75029. */
  75030. dispose(disableGeometryBufferRenderer?: boolean): void;
  75031. private _createBlurPostProcess;
  75032. /** @hidden */
  75033. _rebuild(): void;
  75034. private _bits;
  75035. private _radicalInverse_VdC;
  75036. private _hammersley;
  75037. private _hemisphereSample_uniform;
  75038. private _generateHemisphere;
  75039. private _getDefinesForSSAO;
  75040. private static readonly ORTHO_DEPTH_PROJECTION;
  75041. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  75042. private _createSSAOPostProcess;
  75043. private _createSSAOCombinePostProcess;
  75044. private _createRandomTexture;
  75045. /**
  75046. * Serialize the rendering pipeline (Used when exporting)
  75047. * @returns the serialized object
  75048. */
  75049. serialize(): any;
  75050. /**
  75051. * Parse the serialized pipeline
  75052. * @param source Source pipeline.
  75053. * @param scene The scene to load the pipeline to.
  75054. * @param rootUrl The URL of the serialized pipeline.
  75055. * @returns An instantiated pipeline from the serialized object.
  75056. */
  75057. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75058. }
  75059. }
  75060. declare module BABYLON {
  75061. /** @hidden */
  75062. export var ssaoPixelShader: {
  75063. name: string;
  75064. shader: string;
  75065. };
  75066. }
  75067. declare module BABYLON {
  75068. /**
  75069. * Render pipeline to produce ssao effect
  75070. */
  75071. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75072. /**
  75073. * @ignore
  75074. * The PassPostProcess id in the pipeline that contains the original scene color
  75075. */
  75076. SSAOOriginalSceneColorEffect: string;
  75077. /**
  75078. * @ignore
  75079. * The SSAO PostProcess id in the pipeline
  75080. */
  75081. SSAORenderEffect: string;
  75082. /**
  75083. * @ignore
  75084. * The horizontal blur PostProcess id in the pipeline
  75085. */
  75086. SSAOBlurHRenderEffect: string;
  75087. /**
  75088. * @ignore
  75089. * The vertical blur PostProcess id in the pipeline
  75090. */
  75091. SSAOBlurVRenderEffect: string;
  75092. /**
  75093. * @ignore
  75094. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75095. */
  75096. SSAOCombineRenderEffect: string;
  75097. /**
  75098. * The output strength of the SSAO post-process. Default value is 1.0.
  75099. */
  75100. totalStrength: number;
  75101. /**
  75102. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75103. */
  75104. radius: number;
  75105. /**
  75106. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75107. * Must not be equal to fallOff and superior to fallOff.
  75108. * Default value is 0.0075
  75109. */
  75110. area: number;
  75111. /**
  75112. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75113. * Must not be equal to area and inferior to area.
  75114. * Default value is 0.000001
  75115. */
  75116. fallOff: number;
  75117. /**
  75118. * The base color of the SSAO post-process
  75119. * The final result is "base + ssao" between [0, 1]
  75120. */
  75121. base: number;
  75122. private _scene;
  75123. private _depthTexture;
  75124. private _randomTexture;
  75125. private _originalColorPostProcess;
  75126. private _ssaoPostProcess;
  75127. private _blurHPostProcess;
  75128. private _blurVPostProcess;
  75129. private _ssaoCombinePostProcess;
  75130. private _firstUpdate;
  75131. /**
  75132. * Gets active scene
  75133. */
  75134. get scene(): Scene;
  75135. /**
  75136. * @constructor
  75137. * @param name - The rendering pipeline name
  75138. * @param scene - The scene linked to this pipeline
  75139. * @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 }
  75140. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75141. */
  75142. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75143. /**
  75144. * Get the class name
  75145. * @returns "SSAORenderingPipeline"
  75146. */
  75147. getClassName(): string;
  75148. /**
  75149. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75150. */
  75151. dispose(disableDepthRender?: boolean): void;
  75152. private _createBlurPostProcess;
  75153. /** @hidden */
  75154. _rebuild(): void;
  75155. private _createSSAOPostProcess;
  75156. private _createSSAOCombinePostProcess;
  75157. private _createRandomTexture;
  75158. }
  75159. }
  75160. declare module BABYLON {
  75161. /**
  75162. * Contains all parameters needed for the prepass to perform
  75163. * screen space reflections
  75164. */
  75165. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75166. /**
  75167. * Is ssr enabled
  75168. */
  75169. enabled: boolean;
  75170. /**
  75171. * Name of the configuration
  75172. */
  75173. name: string;
  75174. /**
  75175. * Textures that should be present in the MRT for this effect to work
  75176. */
  75177. readonly texturesRequired: number[];
  75178. }
  75179. }
  75180. declare module BABYLON {
  75181. /** @hidden */
  75182. export var screenSpaceReflectionPixelShader: {
  75183. name: string;
  75184. shader: string;
  75185. };
  75186. }
  75187. declare module BABYLON {
  75188. /**
  75189. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75190. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75191. */
  75192. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75193. /**
  75194. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75195. */
  75196. threshold: number;
  75197. /**
  75198. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75199. */
  75200. strength: number;
  75201. /**
  75202. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75203. */
  75204. reflectionSpecularFalloffExponent: number;
  75205. /**
  75206. * 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]
  75207. */
  75208. step: number;
  75209. /**
  75210. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75211. */
  75212. roughnessFactor: number;
  75213. private _forceGeometryBuffer;
  75214. private _geometryBufferRenderer;
  75215. private _prePassRenderer;
  75216. private _enableSmoothReflections;
  75217. private _reflectionSamples;
  75218. private _smoothSteps;
  75219. /**
  75220. * Gets a string identifying the name of the class
  75221. * @returns "ScreenSpaceReflectionPostProcess" string
  75222. */
  75223. getClassName(): string;
  75224. /**
  75225. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75226. * @param name The name of the effect.
  75227. * @param scene The scene containing the objects to calculate reflections.
  75228. * @param options The required width/height ratio to downsize to before computing the render pass.
  75229. * @param camera The camera to apply the render pass to.
  75230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75231. * @param engine The engine which the post process will be applied. (default: current engine)
  75232. * @param reusable If the post process can be reused on the same frame. (default: false)
  75233. * @param textureType Type of textures used when performing the post process. (default: 0)
  75234. * @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)
  75235. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75236. */
  75237. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75238. /**
  75239. * Gets wether or not smoothing reflections is enabled.
  75240. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75241. */
  75242. get enableSmoothReflections(): boolean;
  75243. /**
  75244. * Sets wether or not smoothing reflections is enabled.
  75245. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75246. */
  75247. set enableSmoothReflections(enabled: boolean);
  75248. /**
  75249. * Gets the number of samples taken while computing reflections. More samples count is high,
  75250. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75251. */
  75252. get reflectionSamples(): number;
  75253. /**
  75254. * Sets the number of samples taken while computing reflections. More samples count is high,
  75255. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75256. */
  75257. set reflectionSamples(samples: number);
  75258. /**
  75259. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75260. * more the post-process will require GPU power and can generate a drop in FPS.
  75261. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75262. */
  75263. get smoothSteps(): number;
  75264. set smoothSteps(steps: number);
  75265. private _updateEffectDefines;
  75266. /** @hidden */
  75267. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75268. }
  75269. }
  75270. declare module BABYLON {
  75271. /** @hidden */
  75272. export var standardPixelShader: {
  75273. name: string;
  75274. shader: string;
  75275. };
  75276. }
  75277. declare module BABYLON {
  75278. /**
  75279. * Standard rendering pipeline
  75280. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75281. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75282. */
  75283. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75284. /**
  75285. * Public members
  75286. */
  75287. /**
  75288. * Post-process which contains the original scene color before the pipeline applies all the effects
  75289. */
  75290. originalPostProcess: Nullable<PostProcess>;
  75291. /**
  75292. * Post-process used to down scale an image x4
  75293. */
  75294. downSampleX4PostProcess: Nullable<PostProcess>;
  75295. /**
  75296. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75297. */
  75298. brightPassPostProcess: Nullable<PostProcess>;
  75299. /**
  75300. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75301. */
  75302. blurHPostProcesses: PostProcess[];
  75303. /**
  75304. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75305. */
  75306. blurVPostProcesses: PostProcess[];
  75307. /**
  75308. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75309. */
  75310. textureAdderPostProcess: Nullable<PostProcess>;
  75311. /**
  75312. * Post-process used to create volumetric lighting effect
  75313. */
  75314. volumetricLightPostProcess: Nullable<PostProcess>;
  75315. /**
  75316. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75317. */
  75318. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75319. /**
  75320. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75321. */
  75322. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75323. /**
  75324. * Post-process used to merge the volumetric light effect and the real scene color
  75325. */
  75326. volumetricLightMergePostProces: Nullable<PostProcess>;
  75327. /**
  75328. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75329. */
  75330. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75331. /**
  75332. * Base post-process used to calculate the average luminance of the final image for HDR
  75333. */
  75334. luminancePostProcess: Nullable<PostProcess>;
  75335. /**
  75336. * Post-processes used to create down sample post-processes in order to get
  75337. * the average luminance of the final image for HDR
  75338. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75339. */
  75340. luminanceDownSamplePostProcesses: PostProcess[];
  75341. /**
  75342. * Post-process used to create a HDR effect (light adaptation)
  75343. */
  75344. hdrPostProcess: Nullable<PostProcess>;
  75345. /**
  75346. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75347. */
  75348. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75349. /**
  75350. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75351. */
  75352. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75353. /**
  75354. * Post-process used to merge the final HDR post-process and the real scene color
  75355. */
  75356. hdrFinalPostProcess: Nullable<PostProcess>;
  75357. /**
  75358. * Post-process used to create a lens flare effect
  75359. */
  75360. lensFlarePostProcess: Nullable<PostProcess>;
  75361. /**
  75362. * Post-process that merges the result of the lens flare post-process and the real scene color
  75363. */
  75364. lensFlareComposePostProcess: Nullable<PostProcess>;
  75365. /**
  75366. * Post-process used to create a motion blur effect
  75367. */
  75368. motionBlurPostProcess: Nullable<PostProcess>;
  75369. /**
  75370. * Post-process used to create a depth of field effect
  75371. */
  75372. depthOfFieldPostProcess: Nullable<PostProcess>;
  75373. /**
  75374. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75375. */
  75376. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75377. /**
  75378. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75379. */
  75380. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75381. /**
  75382. * Represents the brightness threshold in order to configure the illuminated surfaces
  75383. */
  75384. brightThreshold: number;
  75385. /**
  75386. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75387. */
  75388. blurWidth: number;
  75389. /**
  75390. * Sets if the blur for highlighted surfaces must be only horizontal
  75391. */
  75392. horizontalBlur: boolean;
  75393. /**
  75394. * Gets the overall exposure used by the pipeline
  75395. */
  75396. get exposure(): number;
  75397. /**
  75398. * Sets the overall exposure used by the pipeline
  75399. */
  75400. set exposure(value: number);
  75401. /**
  75402. * Texture used typically to simulate "dirty" on camera lens
  75403. */
  75404. lensTexture: Nullable<Texture>;
  75405. /**
  75406. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75407. */
  75408. volumetricLightCoefficient: number;
  75409. /**
  75410. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75411. */
  75412. volumetricLightPower: number;
  75413. /**
  75414. * Used the set the blur intensity to smooth the volumetric lights
  75415. */
  75416. volumetricLightBlurScale: number;
  75417. /**
  75418. * Light (spot or directional) used to generate the volumetric lights rays
  75419. * The source light must have a shadow generate so the pipeline can get its
  75420. * depth map
  75421. */
  75422. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75423. /**
  75424. * For eye adaptation, represents the minimum luminance the eye can see
  75425. */
  75426. hdrMinimumLuminance: number;
  75427. /**
  75428. * For eye adaptation, represents the decrease luminance speed
  75429. */
  75430. hdrDecreaseRate: number;
  75431. /**
  75432. * For eye adaptation, represents the increase luminance speed
  75433. */
  75434. hdrIncreaseRate: number;
  75435. /**
  75436. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75437. */
  75438. get hdrAutoExposure(): boolean;
  75439. /**
  75440. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75441. */
  75442. set hdrAutoExposure(value: boolean);
  75443. /**
  75444. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75445. */
  75446. lensColorTexture: Nullable<Texture>;
  75447. /**
  75448. * The overall strengh for the lens flare effect
  75449. */
  75450. lensFlareStrength: number;
  75451. /**
  75452. * Dispersion coefficient for lens flare ghosts
  75453. */
  75454. lensFlareGhostDispersal: number;
  75455. /**
  75456. * Main lens flare halo width
  75457. */
  75458. lensFlareHaloWidth: number;
  75459. /**
  75460. * Based on the lens distortion effect, defines how much the lens flare result
  75461. * is distorted
  75462. */
  75463. lensFlareDistortionStrength: number;
  75464. /**
  75465. * Configures the blur intensity used for for lens flare (halo)
  75466. */
  75467. lensFlareBlurWidth: number;
  75468. /**
  75469. * Lens star texture must be used to simulate rays on the flares and is available
  75470. * in the documentation
  75471. */
  75472. lensStarTexture: Nullable<Texture>;
  75473. /**
  75474. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75475. * flare effect by taking account of the dirt texture
  75476. */
  75477. lensFlareDirtTexture: Nullable<Texture>;
  75478. /**
  75479. * Represents the focal length for the depth of field effect
  75480. */
  75481. depthOfFieldDistance: number;
  75482. /**
  75483. * Represents the blur intensity for the blurred part of the depth of field effect
  75484. */
  75485. depthOfFieldBlurWidth: number;
  75486. /**
  75487. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75488. */
  75489. get motionStrength(): number;
  75490. /**
  75491. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75492. */
  75493. set motionStrength(strength: number);
  75494. /**
  75495. * Gets wether or not the motion blur post-process is object based or screen based.
  75496. */
  75497. get objectBasedMotionBlur(): boolean;
  75498. /**
  75499. * Sets wether or not the motion blur post-process should be object based or screen based
  75500. */
  75501. set objectBasedMotionBlur(value: boolean);
  75502. /**
  75503. * List of animations for the pipeline (IAnimatable implementation)
  75504. */
  75505. animations: Animation[];
  75506. /**
  75507. * Private members
  75508. */
  75509. private _scene;
  75510. private _currentDepthOfFieldSource;
  75511. private _basePostProcess;
  75512. private _fixedExposure;
  75513. private _currentExposure;
  75514. private _hdrAutoExposure;
  75515. private _hdrCurrentLuminance;
  75516. private _motionStrength;
  75517. private _isObjectBasedMotionBlur;
  75518. private _floatTextureType;
  75519. private _camerasToBeAttached;
  75520. private _ratio;
  75521. private _bloomEnabled;
  75522. private _depthOfFieldEnabled;
  75523. private _vlsEnabled;
  75524. private _lensFlareEnabled;
  75525. private _hdrEnabled;
  75526. private _motionBlurEnabled;
  75527. private _fxaaEnabled;
  75528. private _screenSpaceReflectionsEnabled;
  75529. private _motionBlurSamples;
  75530. private _volumetricLightStepsCount;
  75531. private _samples;
  75532. /**
  75533. * @ignore
  75534. * Specifies if the bloom pipeline is enabled
  75535. */
  75536. get BloomEnabled(): boolean;
  75537. set BloomEnabled(enabled: boolean);
  75538. /**
  75539. * @ignore
  75540. * Specifies if the depth of field pipeline is enabed
  75541. */
  75542. get DepthOfFieldEnabled(): boolean;
  75543. set DepthOfFieldEnabled(enabled: boolean);
  75544. /**
  75545. * @ignore
  75546. * Specifies if the lens flare pipeline is enabed
  75547. */
  75548. get LensFlareEnabled(): boolean;
  75549. set LensFlareEnabled(enabled: boolean);
  75550. /**
  75551. * @ignore
  75552. * Specifies if the HDR pipeline is enabled
  75553. */
  75554. get HDREnabled(): boolean;
  75555. set HDREnabled(enabled: boolean);
  75556. /**
  75557. * @ignore
  75558. * Specifies if the volumetric lights scattering effect is enabled
  75559. */
  75560. get VLSEnabled(): boolean;
  75561. set VLSEnabled(enabled: boolean);
  75562. /**
  75563. * @ignore
  75564. * Specifies if the motion blur effect is enabled
  75565. */
  75566. get MotionBlurEnabled(): boolean;
  75567. set MotionBlurEnabled(enabled: boolean);
  75568. /**
  75569. * Specifies if anti-aliasing is enabled
  75570. */
  75571. get fxaaEnabled(): boolean;
  75572. set fxaaEnabled(enabled: boolean);
  75573. /**
  75574. * Specifies if screen space reflections are enabled.
  75575. */
  75576. get screenSpaceReflectionsEnabled(): boolean;
  75577. set screenSpaceReflectionsEnabled(enabled: boolean);
  75578. /**
  75579. * Specifies the number of steps used to calculate the volumetric lights
  75580. * Typically in interval [50, 200]
  75581. */
  75582. get volumetricLightStepsCount(): number;
  75583. set volumetricLightStepsCount(count: number);
  75584. /**
  75585. * Specifies the number of samples used for the motion blur effect
  75586. * Typically in interval [16, 64]
  75587. */
  75588. get motionBlurSamples(): number;
  75589. set motionBlurSamples(samples: number);
  75590. /**
  75591. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75592. */
  75593. get samples(): number;
  75594. set samples(sampleCount: number);
  75595. /**
  75596. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75597. * @constructor
  75598. * @param name The rendering pipeline name
  75599. * @param scene The scene linked to this pipeline
  75600. * @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)
  75601. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75602. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75603. */
  75604. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75605. private _buildPipeline;
  75606. private _createDownSampleX4PostProcess;
  75607. private _createBrightPassPostProcess;
  75608. private _createBlurPostProcesses;
  75609. private _createTextureAdderPostProcess;
  75610. private _createVolumetricLightPostProcess;
  75611. private _createLuminancePostProcesses;
  75612. private _createHdrPostProcess;
  75613. private _createLensFlarePostProcess;
  75614. private _createDepthOfFieldPostProcess;
  75615. private _createMotionBlurPostProcess;
  75616. private _getDepthTexture;
  75617. private _disposePostProcesses;
  75618. /**
  75619. * Dispose of the pipeline and stop all post processes
  75620. */
  75621. dispose(): void;
  75622. /**
  75623. * Serialize the rendering pipeline (Used when exporting)
  75624. * @returns the serialized object
  75625. */
  75626. serialize(): any;
  75627. /**
  75628. * Parse the serialized pipeline
  75629. * @param source Source pipeline.
  75630. * @param scene The scene to load the pipeline to.
  75631. * @param rootUrl The URL of the serialized pipeline.
  75632. * @returns An instantiated pipeline from the serialized object.
  75633. */
  75634. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75635. /**
  75636. * Luminance steps
  75637. */
  75638. static LuminanceSteps: number;
  75639. }
  75640. }
  75641. declare module BABYLON {
  75642. /** @hidden */
  75643. export var stereoscopicInterlacePixelShader: {
  75644. name: string;
  75645. shader: string;
  75646. };
  75647. }
  75648. declare module BABYLON {
  75649. /**
  75650. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75651. */
  75652. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75653. private _stepSize;
  75654. private _passedProcess;
  75655. /**
  75656. * Gets a string identifying the name of the class
  75657. * @returns "StereoscopicInterlacePostProcessI" string
  75658. */
  75659. getClassName(): string;
  75660. /**
  75661. * Initializes a StereoscopicInterlacePostProcessI
  75662. * @param name The name of the effect.
  75663. * @param rigCameras The rig cameras to be appled to the post process
  75664. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75665. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75667. * @param engine The engine which the post process will be applied. (default: current engine)
  75668. * @param reusable If the post process can be reused on the same frame. (default: false)
  75669. */
  75670. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75671. }
  75672. /**
  75673. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75674. */
  75675. export class StereoscopicInterlacePostProcess extends PostProcess {
  75676. private _stepSize;
  75677. private _passedProcess;
  75678. /**
  75679. * Gets a string identifying the name of the class
  75680. * @returns "StereoscopicInterlacePostProcess" string
  75681. */
  75682. getClassName(): string;
  75683. /**
  75684. * Initializes a StereoscopicInterlacePostProcess
  75685. * @param name The name of the effect.
  75686. * @param rigCameras The rig cameras to be appled to the post process
  75687. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75689. * @param engine The engine which the post process will be applied. (default: current engine)
  75690. * @param reusable If the post process can be reused on the same frame. (default: false)
  75691. */
  75692. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75693. }
  75694. }
  75695. declare module BABYLON {
  75696. /** @hidden */
  75697. export var tonemapPixelShader: {
  75698. name: string;
  75699. shader: string;
  75700. };
  75701. }
  75702. declare module BABYLON {
  75703. /** Defines operator used for tonemapping */
  75704. export enum TonemappingOperator {
  75705. /** Hable */
  75706. Hable = 0,
  75707. /** Reinhard */
  75708. Reinhard = 1,
  75709. /** HejiDawson */
  75710. HejiDawson = 2,
  75711. /** Photographic */
  75712. Photographic = 3
  75713. }
  75714. /**
  75715. * Defines a post process to apply tone mapping
  75716. */
  75717. export class TonemapPostProcess extends PostProcess {
  75718. private _operator;
  75719. /** Defines the required exposure adjustement */
  75720. exposureAdjustment: number;
  75721. /**
  75722. * Gets a string identifying the name of the class
  75723. * @returns "TonemapPostProcess" string
  75724. */
  75725. getClassName(): string;
  75726. /**
  75727. * Creates a new TonemapPostProcess
  75728. * @param name defines the name of the postprocess
  75729. * @param _operator defines the operator to use
  75730. * @param exposureAdjustment defines the required exposure adjustement
  75731. * @param camera defines the camera to use (can be null)
  75732. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75733. * @param engine defines the hosting engine (can be ignore if camera is set)
  75734. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75735. */
  75736. constructor(name: string, _operator: TonemappingOperator,
  75737. /** Defines the required exposure adjustement */
  75738. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75739. }
  75740. }
  75741. declare module BABYLON {
  75742. /** @hidden */
  75743. export var volumetricLightScatteringPixelShader: {
  75744. name: string;
  75745. shader: string;
  75746. };
  75747. }
  75748. declare module BABYLON {
  75749. /** @hidden */
  75750. export var volumetricLightScatteringPassVertexShader: {
  75751. name: string;
  75752. shader: string;
  75753. };
  75754. }
  75755. declare module BABYLON {
  75756. /** @hidden */
  75757. export var volumetricLightScatteringPassPixelShader: {
  75758. name: string;
  75759. shader: string;
  75760. };
  75761. }
  75762. declare module BABYLON {
  75763. /**
  75764. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75765. */
  75766. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75767. private _volumetricLightScatteringPass;
  75768. private _volumetricLightScatteringRTT;
  75769. private _viewPort;
  75770. private _screenCoordinates;
  75771. private _cachedDefines;
  75772. /**
  75773. * If not undefined, the mesh position is computed from the attached node position
  75774. */
  75775. attachedNode: {
  75776. position: Vector3;
  75777. };
  75778. /**
  75779. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75780. */
  75781. customMeshPosition: Vector3;
  75782. /**
  75783. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75784. */
  75785. useCustomMeshPosition: boolean;
  75786. /**
  75787. * If the post-process should inverse the light scattering direction
  75788. */
  75789. invert: boolean;
  75790. /**
  75791. * The internal mesh used by the post-process
  75792. */
  75793. mesh: Mesh;
  75794. /**
  75795. * @hidden
  75796. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75797. */
  75798. get useDiffuseColor(): boolean;
  75799. set useDiffuseColor(useDiffuseColor: boolean);
  75800. /**
  75801. * Array containing the excluded meshes not rendered in the internal pass
  75802. */
  75803. excludedMeshes: AbstractMesh[];
  75804. /**
  75805. * Controls the overall intensity of the post-process
  75806. */
  75807. exposure: number;
  75808. /**
  75809. * Dissipates each sample's contribution in range [0, 1]
  75810. */
  75811. decay: number;
  75812. /**
  75813. * Controls the overall intensity of each sample
  75814. */
  75815. weight: number;
  75816. /**
  75817. * Controls the density of each sample
  75818. */
  75819. density: number;
  75820. /**
  75821. * @constructor
  75822. * @param name The post-process name
  75823. * @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)
  75824. * @param camera The camera that the post-process will be attached to
  75825. * @param mesh The mesh used to create the light scattering
  75826. * @param samples The post-process quality, default 100
  75827. * @param samplingModeThe post-process filtering mode
  75828. * @param engine The babylon engine
  75829. * @param reusable If the post-process is reusable
  75830. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75831. */
  75832. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75833. /**
  75834. * Returns the string "VolumetricLightScatteringPostProcess"
  75835. * @returns "VolumetricLightScatteringPostProcess"
  75836. */
  75837. getClassName(): string;
  75838. private _isReady;
  75839. /**
  75840. * Sets the new light position for light scattering effect
  75841. * @param position The new custom light position
  75842. */
  75843. setCustomMeshPosition(position: Vector3): void;
  75844. /**
  75845. * Returns the light position for light scattering effect
  75846. * @return Vector3 The custom light position
  75847. */
  75848. getCustomMeshPosition(): Vector3;
  75849. /**
  75850. * Disposes the internal assets and detaches the post-process from the camera
  75851. */
  75852. dispose(camera: Camera): void;
  75853. /**
  75854. * Returns the render target texture used by the post-process
  75855. * @return the render target texture used by the post-process
  75856. */
  75857. getPass(): RenderTargetTexture;
  75858. private _meshExcluded;
  75859. private _createPass;
  75860. private _updateMeshScreenCoordinates;
  75861. /**
  75862. * Creates a default mesh for the Volumeric Light Scattering post-process
  75863. * @param name The mesh name
  75864. * @param scene The scene where to create the mesh
  75865. * @return the default mesh
  75866. */
  75867. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75868. }
  75869. }
  75870. declare module BABYLON {
  75871. /** @hidden */
  75872. export var screenSpaceCurvaturePixelShader: {
  75873. name: string;
  75874. shader: string;
  75875. };
  75876. }
  75877. declare module BABYLON {
  75878. /**
  75879. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75880. */
  75881. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75882. /**
  75883. * Defines how much ridge the curvature effect displays.
  75884. */
  75885. ridge: number;
  75886. /**
  75887. * Defines how much valley the curvature effect displays.
  75888. */
  75889. valley: number;
  75890. private _geometryBufferRenderer;
  75891. /**
  75892. * Gets a string identifying the name of the class
  75893. * @returns "ScreenSpaceCurvaturePostProcess" string
  75894. */
  75895. getClassName(): string;
  75896. /**
  75897. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75898. * @param name The name of the effect.
  75899. * @param scene The scene containing the objects to blur according to their velocity.
  75900. * @param options The required width/height ratio to downsize to before computing the render pass.
  75901. * @param camera The camera to apply the render pass to.
  75902. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75903. * @param engine The engine which the post process will be applied. (default: current engine)
  75904. * @param reusable If the post process can be reused on the same frame. (default: false)
  75905. * @param textureType Type of textures used when performing the post process. (default: 0)
  75906. * @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)
  75907. */
  75908. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75909. /**
  75910. * Support test.
  75911. */
  75912. static get IsSupported(): boolean;
  75913. /** @hidden */
  75914. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75915. }
  75916. }
  75917. declare module BABYLON {
  75918. interface Scene {
  75919. /** @hidden (Backing field) */
  75920. _boundingBoxRenderer: BoundingBoxRenderer;
  75921. /** @hidden (Backing field) */
  75922. _forceShowBoundingBoxes: boolean;
  75923. /**
  75924. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75925. */
  75926. forceShowBoundingBoxes: boolean;
  75927. /**
  75928. * Gets the bounding box renderer associated with the scene
  75929. * @returns a BoundingBoxRenderer
  75930. */
  75931. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75932. }
  75933. interface AbstractMesh {
  75934. /** @hidden (Backing field) */
  75935. _showBoundingBox: boolean;
  75936. /**
  75937. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75938. */
  75939. showBoundingBox: boolean;
  75940. }
  75941. /**
  75942. * Component responsible of rendering the bounding box of the meshes in a scene.
  75943. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75944. */
  75945. export class BoundingBoxRenderer implements ISceneComponent {
  75946. /**
  75947. * The component name helpfull to identify the component in the list of scene components.
  75948. */
  75949. readonly name: string;
  75950. /**
  75951. * The scene the component belongs to.
  75952. */
  75953. scene: Scene;
  75954. /**
  75955. * Color of the bounding box lines placed in front of an object
  75956. */
  75957. frontColor: Color3;
  75958. /**
  75959. * Color of the bounding box lines placed behind an object
  75960. */
  75961. backColor: Color3;
  75962. /**
  75963. * Defines if the renderer should show the back lines or not
  75964. */
  75965. showBackLines: boolean;
  75966. /**
  75967. * Observable raised before rendering a bounding box
  75968. */
  75969. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75970. /**
  75971. * Observable raised after rendering a bounding box
  75972. */
  75973. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75974. /**
  75975. * Observable raised after resources are created
  75976. */
  75977. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  75978. /**
  75979. * When false, no bounding boxes will be rendered
  75980. */
  75981. enabled: boolean;
  75982. /**
  75983. * @hidden
  75984. */
  75985. renderList: SmartArray<BoundingBox>;
  75986. private _colorShader;
  75987. private _vertexBuffers;
  75988. private _indexBuffer;
  75989. private _fillIndexBuffer;
  75990. private _fillIndexData;
  75991. /**
  75992. * Instantiates a new bounding box renderer in a scene.
  75993. * @param scene the scene the renderer renders in
  75994. */
  75995. constructor(scene: Scene);
  75996. /**
  75997. * Registers the component in a given scene
  75998. */
  75999. register(): void;
  76000. private _evaluateSubMesh;
  76001. private _preActiveMesh;
  76002. private _prepareResources;
  76003. private _createIndexBuffer;
  76004. /**
  76005. * Rebuilds the elements related to this component in case of
  76006. * context lost for instance.
  76007. */
  76008. rebuild(): void;
  76009. /**
  76010. * @hidden
  76011. */
  76012. reset(): void;
  76013. /**
  76014. * Render the bounding boxes of a specific rendering group
  76015. * @param renderingGroupId defines the rendering group to render
  76016. */
  76017. render(renderingGroupId: number): void;
  76018. /**
  76019. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76020. * @param mesh Define the mesh to render the occlusion bounding box for
  76021. */
  76022. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76023. /**
  76024. * Dispose and release the resources attached to this renderer.
  76025. */
  76026. dispose(): void;
  76027. }
  76028. }
  76029. declare module BABYLON {
  76030. interface Scene {
  76031. /** @hidden (Backing field) */
  76032. _depthRenderer: {
  76033. [id: string]: DepthRenderer;
  76034. };
  76035. /**
  76036. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76037. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76038. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76039. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76040. * @returns the created depth renderer
  76041. */
  76042. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76043. /**
  76044. * Disables a depth renderer for a given camera
  76045. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76046. */
  76047. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76048. }
  76049. /**
  76050. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76051. * in several rendering techniques.
  76052. */
  76053. export class DepthRendererSceneComponent implements ISceneComponent {
  76054. /**
  76055. * The component name helpfull to identify the component in the list of scene components.
  76056. */
  76057. readonly name: string;
  76058. /**
  76059. * The scene the component belongs to.
  76060. */
  76061. scene: Scene;
  76062. /**
  76063. * Creates a new instance of the component for the given scene
  76064. * @param scene Defines the scene to register the component in
  76065. */
  76066. constructor(scene: Scene);
  76067. /**
  76068. * Registers the component in a given scene
  76069. */
  76070. register(): void;
  76071. /**
  76072. * Rebuilds the elements related to this component in case of
  76073. * context lost for instance.
  76074. */
  76075. rebuild(): void;
  76076. /**
  76077. * Disposes the component and the associated ressources
  76078. */
  76079. dispose(): void;
  76080. private _gatherRenderTargets;
  76081. private _gatherActiveCameraRenderTargets;
  76082. }
  76083. }
  76084. declare module BABYLON {
  76085. interface AbstractScene {
  76086. /** @hidden (Backing field) */
  76087. _prePassRenderer: Nullable<PrePassRenderer>;
  76088. /**
  76089. * Gets or Sets the current prepass renderer associated to the scene.
  76090. */
  76091. prePassRenderer: Nullable<PrePassRenderer>;
  76092. /**
  76093. * Enables the prepass and associates it with the scene
  76094. * @returns the PrePassRenderer
  76095. */
  76096. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76097. /**
  76098. * Disables the prepass associated with the scene
  76099. */
  76100. disablePrePassRenderer(): void;
  76101. }
  76102. /**
  76103. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76104. * in several rendering techniques.
  76105. */
  76106. export class PrePassRendererSceneComponent implements ISceneComponent {
  76107. /**
  76108. * The component name helpful to identify the component in the list of scene components.
  76109. */
  76110. readonly name: string;
  76111. /**
  76112. * The scene the component belongs to.
  76113. */
  76114. scene: Scene;
  76115. /**
  76116. * Creates a new instance of the component for the given scene
  76117. * @param scene Defines the scene to register the component in
  76118. */
  76119. constructor(scene: Scene);
  76120. /**
  76121. * Registers the component in a given scene
  76122. */
  76123. register(): void;
  76124. private _beforeCameraDraw;
  76125. private _afterCameraDraw;
  76126. private _beforeClearStage;
  76127. private _beforeRenderingMeshStage;
  76128. private _afterRenderingMeshStage;
  76129. /**
  76130. * Rebuilds the elements related to this component in case of
  76131. * context lost for instance.
  76132. */
  76133. rebuild(): void;
  76134. /**
  76135. * Disposes the component and the associated ressources
  76136. */
  76137. dispose(): void;
  76138. }
  76139. }
  76140. declare module BABYLON {
  76141. /** @hidden */
  76142. export var fibonacci: {
  76143. name: string;
  76144. shader: string;
  76145. };
  76146. }
  76147. declare module BABYLON {
  76148. /** @hidden */
  76149. export var diffusionProfile: {
  76150. name: string;
  76151. shader: string;
  76152. };
  76153. }
  76154. declare module BABYLON {
  76155. /** @hidden */
  76156. export var subSurfaceScatteringPixelShader: {
  76157. name: string;
  76158. shader: string;
  76159. };
  76160. }
  76161. declare module BABYLON {
  76162. /**
  76163. * Sub surface scattering post process
  76164. */
  76165. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76166. /**
  76167. * Gets a string identifying the name of the class
  76168. * @returns "SubSurfaceScatteringPostProcess" string
  76169. */
  76170. getClassName(): string;
  76171. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76172. }
  76173. }
  76174. declare module BABYLON {
  76175. /**
  76176. * Contains all parameters needed for the prepass to perform
  76177. * screen space subsurface scattering
  76178. */
  76179. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76180. /** @hidden */
  76181. static _SceneComponentInitialization: (scene: Scene) => void;
  76182. private _ssDiffusionS;
  76183. private _ssFilterRadii;
  76184. private _ssDiffusionD;
  76185. /**
  76186. * Post process to attach for screen space subsurface scattering
  76187. */
  76188. postProcess: SubSurfaceScatteringPostProcess;
  76189. /**
  76190. * Diffusion profile color for subsurface scattering
  76191. */
  76192. get ssDiffusionS(): number[];
  76193. /**
  76194. * Diffusion profile max color channel value for subsurface scattering
  76195. */
  76196. get ssDiffusionD(): number[];
  76197. /**
  76198. * Diffusion profile filter radius for subsurface scattering
  76199. */
  76200. get ssFilterRadii(): number[];
  76201. /**
  76202. * Is subsurface enabled
  76203. */
  76204. enabled: boolean;
  76205. /**
  76206. * Name of the configuration
  76207. */
  76208. name: string;
  76209. /**
  76210. * Diffusion profile colors for subsurface scattering
  76211. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76212. * See ...
  76213. * Note that you can only store up to 5 of them
  76214. */
  76215. ssDiffusionProfileColors: Color3[];
  76216. /**
  76217. * Defines the ratio real world => scene units.
  76218. * Used for subsurface scattering
  76219. */
  76220. metersPerUnit: number;
  76221. /**
  76222. * Textures that should be present in the MRT for this effect to work
  76223. */
  76224. readonly texturesRequired: number[];
  76225. private _scene;
  76226. /**
  76227. * Builds a subsurface configuration object
  76228. * @param scene The scene
  76229. */
  76230. constructor(scene: Scene);
  76231. /**
  76232. * Adds a new diffusion profile.
  76233. * Useful for more realistic subsurface scattering on diverse materials.
  76234. * @param color The color of the diffusion profile. Should be the average color of the material.
  76235. * @return The index of the diffusion profile for the material subsurface configuration
  76236. */
  76237. addDiffusionProfile(color: Color3): number;
  76238. /**
  76239. * Creates the sss post process
  76240. * @return The created post process
  76241. */
  76242. createPostProcess(): SubSurfaceScatteringPostProcess;
  76243. /**
  76244. * Deletes all diffusion profiles.
  76245. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76246. */
  76247. clearAllDiffusionProfiles(): void;
  76248. /**
  76249. * Disposes this object
  76250. */
  76251. dispose(): void;
  76252. /**
  76253. * @hidden
  76254. * https://zero-radiance.github.io/post/sampling-diffusion/
  76255. *
  76256. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76257. * ------------------------------------------------------------------------------------
  76258. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76259. * PDF[r, phi, s] = r * R[r, phi, s]
  76260. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76261. * ------------------------------------------------------------------------------------
  76262. * We importance sample the color channel with the widest scattering distance.
  76263. */
  76264. getDiffusionProfileParameters(color: Color3): number;
  76265. /**
  76266. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76267. * 'u' is the random number (the value of the CDF): [0, 1).
  76268. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76269. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76270. */
  76271. private _sampleBurleyDiffusionProfile;
  76272. }
  76273. }
  76274. declare module BABYLON {
  76275. interface AbstractScene {
  76276. /** @hidden (Backing field) */
  76277. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76278. /**
  76279. * Gets or Sets the current prepass renderer associated to the scene.
  76280. */
  76281. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76282. /**
  76283. * Enables the subsurface effect for prepass
  76284. * @returns the SubSurfaceConfiguration
  76285. */
  76286. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76287. /**
  76288. * Disables the subsurface effect for prepass
  76289. */
  76290. disableSubSurfaceForPrePass(): void;
  76291. }
  76292. /**
  76293. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76294. * in several rendering techniques.
  76295. */
  76296. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76297. /**
  76298. * The component name helpful to identify the component in the list of scene components.
  76299. */
  76300. readonly name: string;
  76301. /**
  76302. * The scene the component belongs to.
  76303. */
  76304. scene: Scene;
  76305. /**
  76306. * Creates a new instance of the component for the given scene
  76307. * @param scene Defines the scene to register the component in
  76308. */
  76309. constructor(scene: Scene);
  76310. /**
  76311. * Registers the component in a given scene
  76312. */
  76313. register(): void;
  76314. /**
  76315. * Serializes the component data to the specified json object
  76316. * @param serializationObject The object to serialize to
  76317. */
  76318. serialize(serializationObject: any): void;
  76319. /**
  76320. * Adds all the elements from the container to the scene
  76321. * @param container the container holding the elements
  76322. */
  76323. addFromContainer(container: AbstractScene): void;
  76324. /**
  76325. * Removes all the elements in the container from the scene
  76326. * @param container contains the elements to remove
  76327. * @param dispose if the removed element should be disposed (default: false)
  76328. */
  76329. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76330. /**
  76331. * Rebuilds the elements related to this component in case of
  76332. * context lost for instance.
  76333. */
  76334. rebuild(): void;
  76335. /**
  76336. * Disposes the component and the associated ressources
  76337. */
  76338. dispose(): void;
  76339. }
  76340. }
  76341. declare module BABYLON {
  76342. /** @hidden */
  76343. export var outlinePixelShader: {
  76344. name: string;
  76345. shader: string;
  76346. };
  76347. }
  76348. declare module BABYLON {
  76349. /** @hidden */
  76350. export var outlineVertexShader: {
  76351. name: string;
  76352. shader: string;
  76353. };
  76354. }
  76355. declare module BABYLON {
  76356. interface Scene {
  76357. /** @hidden */
  76358. _outlineRenderer: OutlineRenderer;
  76359. /**
  76360. * Gets the outline renderer associated with the scene
  76361. * @returns a OutlineRenderer
  76362. */
  76363. getOutlineRenderer(): OutlineRenderer;
  76364. }
  76365. interface AbstractMesh {
  76366. /** @hidden (Backing field) */
  76367. _renderOutline: boolean;
  76368. /**
  76369. * Gets or sets a boolean indicating if the outline must be rendered as well
  76370. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76371. */
  76372. renderOutline: boolean;
  76373. /** @hidden (Backing field) */
  76374. _renderOverlay: boolean;
  76375. /**
  76376. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76377. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76378. */
  76379. renderOverlay: boolean;
  76380. }
  76381. /**
  76382. * This class is responsible to draw bothe outline/overlay of meshes.
  76383. * It should not be used directly but through the available method on mesh.
  76384. */
  76385. export class OutlineRenderer implements ISceneComponent {
  76386. /**
  76387. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76388. */
  76389. private static _StencilReference;
  76390. /**
  76391. * The name of the component. Each component must have a unique name.
  76392. */
  76393. name: string;
  76394. /**
  76395. * The scene the component belongs to.
  76396. */
  76397. scene: Scene;
  76398. /**
  76399. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76400. */
  76401. zOffset: number;
  76402. private _engine;
  76403. private _effect;
  76404. private _cachedDefines;
  76405. private _savedDepthWrite;
  76406. /**
  76407. * Instantiates a new outline renderer. (There could be only one per scene).
  76408. * @param scene Defines the scene it belongs to
  76409. */
  76410. constructor(scene: Scene);
  76411. /**
  76412. * Register the component to one instance of a scene.
  76413. */
  76414. register(): void;
  76415. /**
  76416. * Rebuilds the elements related to this component in case of
  76417. * context lost for instance.
  76418. */
  76419. rebuild(): void;
  76420. /**
  76421. * Disposes the component and the associated ressources.
  76422. */
  76423. dispose(): void;
  76424. /**
  76425. * Renders the outline in the canvas.
  76426. * @param subMesh Defines the sumesh to render
  76427. * @param batch Defines the batch of meshes in case of instances
  76428. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76429. */
  76430. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76431. /**
  76432. * Returns whether or not the outline renderer is ready for a given submesh.
  76433. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76434. * @param subMesh Defines the submesh to check readyness for
  76435. * @param useInstances Defines wheter wee are trying to render instances or not
  76436. * @returns true if ready otherwise false
  76437. */
  76438. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76439. private _beforeRenderingMesh;
  76440. private _afterRenderingMesh;
  76441. }
  76442. }
  76443. declare module BABYLON {
  76444. /**
  76445. * Defines the basic options interface of a Sprite Frame Source Size.
  76446. */
  76447. export interface ISpriteJSONSpriteSourceSize {
  76448. /**
  76449. * number of the original width of the Frame
  76450. */
  76451. w: number;
  76452. /**
  76453. * number of the original height of the Frame
  76454. */
  76455. h: number;
  76456. }
  76457. /**
  76458. * Defines the basic options interface of a Sprite Frame Data.
  76459. */
  76460. export interface ISpriteJSONSpriteFrameData {
  76461. /**
  76462. * number of the x offset of the Frame
  76463. */
  76464. x: number;
  76465. /**
  76466. * number of the y offset of the Frame
  76467. */
  76468. y: number;
  76469. /**
  76470. * number of the width of the Frame
  76471. */
  76472. w: number;
  76473. /**
  76474. * number of the height of the Frame
  76475. */
  76476. h: number;
  76477. }
  76478. /**
  76479. * Defines the basic options interface of a JSON Sprite.
  76480. */
  76481. export interface ISpriteJSONSprite {
  76482. /**
  76483. * string name of the Frame
  76484. */
  76485. filename: string;
  76486. /**
  76487. * ISpriteJSONSpriteFrame basic object of the frame data
  76488. */
  76489. frame: ISpriteJSONSpriteFrameData;
  76490. /**
  76491. * boolean to flag is the frame was rotated.
  76492. */
  76493. rotated: boolean;
  76494. /**
  76495. * boolean to flag is the frame was trimmed.
  76496. */
  76497. trimmed: boolean;
  76498. /**
  76499. * ISpriteJSONSpriteFrame basic object of the source data
  76500. */
  76501. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76502. /**
  76503. * ISpriteJSONSpriteFrame basic object of the source data
  76504. */
  76505. sourceSize: ISpriteJSONSpriteSourceSize;
  76506. }
  76507. /**
  76508. * Defines the basic options interface of a JSON atlas.
  76509. */
  76510. export interface ISpriteJSONAtlas {
  76511. /**
  76512. * Array of objects that contain the frame data.
  76513. */
  76514. frames: Array<ISpriteJSONSprite>;
  76515. /**
  76516. * object basic object containing the sprite meta data.
  76517. */
  76518. meta?: object;
  76519. }
  76520. }
  76521. declare module BABYLON {
  76522. /** @hidden */
  76523. export var spriteMapPixelShader: {
  76524. name: string;
  76525. shader: string;
  76526. };
  76527. }
  76528. declare module BABYLON {
  76529. /** @hidden */
  76530. export var spriteMapVertexShader: {
  76531. name: string;
  76532. shader: string;
  76533. };
  76534. }
  76535. declare module BABYLON {
  76536. /**
  76537. * Defines the basic options interface of a SpriteMap
  76538. */
  76539. export interface ISpriteMapOptions {
  76540. /**
  76541. * Vector2 of the number of cells in the grid.
  76542. */
  76543. stageSize?: Vector2;
  76544. /**
  76545. * Vector2 of the size of the output plane in World Units.
  76546. */
  76547. outputSize?: Vector2;
  76548. /**
  76549. * Vector3 of the position of the output plane in World Units.
  76550. */
  76551. outputPosition?: Vector3;
  76552. /**
  76553. * Vector3 of the rotation of the output plane.
  76554. */
  76555. outputRotation?: Vector3;
  76556. /**
  76557. * number of layers that the system will reserve in resources.
  76558. */
  76559. layerCount?: number;
  76560. /**
  76561. * number of max animation frames a single cell will reserve in resources.
  76562. */
  76563. maxAnimationFrames?: number;
  76564. /**
  76565. * number cell index of the base tile when the system compiles.
  76566. */
  76567. baseTile?: number;
  76568. /**
  76569. * boolean flip the sprite after its been repositioned by the framing data.
  76570. */
  76571. flipU?: boolean;
  76572. /**
  76573. * Vector3 scalar of the global RGB values of the SpriteMap.
  76574. */
  76575. colorMultiply?: Vector3;
  76576. }
  76577. /**
  76578. * Defines the IDisposable interface in order to be cleanable from resources.
  76579. */
  76580. export interface ISpriteMap extends IDisposable {
  76581. /**
  76582. * String name of the SpriteMap.
  76583. */
  76584. name: string;
  76585. /**
  76586. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76587. */
  76588. atlasJSON: ISpriteJSONAtlas;
  76589. /**
  76590. * Texture of the SpriteMap.
  76591. */
  76592. spriteSheet: Texture;
  76593. /**
  76594. * The parameters to initialize the SpriteMap with.
  76595. */
  76596. options: ISpriteMapOptions;
  76597. }
  76598. /**
  76599. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76600. */
  76601. export class SpriteMap implements ISpriteMap {
  76602. /** The Name of the spriteMap */
  76603. name: string;
  76604. /** The JSON file with the frame and meta data */
  76605. atlasJSON: ISpriteJSONAtlas;
  76606. /** The systems Sprite Sheet Texture */
  76607. spriteSheet: Texture;
  76608. /** Arguments passed with the Constructor */
  76609. options: ISpriteMapOptions;
  76610. /** Public Sprite Storage array, parsed from atlasJSON */
  76611. sprites: Array<ISpriteJSONSprite>;
  76612. /** Returns the Number of Sprites in the System */
  76613. get spriteCount(): number;
  76614. /** Returns the Position of Output Plane*/
  76615. get position(): Vector3;
  76616. /** Returns the Position of Output Plane*/
  76617. set position(v: Vector3);
  76618. /** Returns the Rotation of Output Plane*/
  76619. get rotation(): Vector3;
  76620. /** Returns the Rotation of Output Plane*/
  76621. set rotation(v: Vector3);
  76622. /** Sets the AnimationMap*/
  76623. get animationMap(): RawTexture;
  76624. /** Sets the AnimationMap*/
  76625. set animationMap(v: RawTexture);
  76626. /** Scene that the SpriteMap was created in */
  76627. private _scene;
  76628. /** Texture Buffer of Float32 that holds tile frame data*/
  76629. private _frameMap;
  76630. /** Texture Buffers of Float32 that holds tileMap data*/
  76631. private _tileMaps;
  76632. /** Texture Buffer of Float32 that holds Animation Data*/
  76633. private _animationMap;
  76634. /** Custom ShaderMaterial Central to the System*/
  76635. private _material;
  76636. /** Custom ShaderMaterial Central to the System*/
  76637. private _output;
  76638. /** Systems Time Ticker*/
  76639. private _time;
  76640. /**
  76641. * Creates a new SpriteMap
  76642. * @param name defines the SpriteMaps Name
  76643. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76644. * @param spriteSheet is the Texture that the Sprites are on.
  76645. * @param options a basic deployment configuration
  76646. * @param scene The Scene that the map is deployed on
  76647. */
  76648. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76649. /**
  76650. * Returns tileID location
  76651. * @returns Vector2 the cell position ID
  76652. */
  76653. getTileID(): Vector2;
  76654. /**
  76655. * Gets the UV location of the mouse over the SpriteMap.
  76656. * @returns Vector2 the UV position of the mouse interaction
  76657. */
  76658. getMousePosition(): Vector2;
  76659. /**
  76660. * Creates the "frame" texture Buffer
  76661. * -------------------------------------
  76662. * Structure of frames
  76663. * "filename": "Falling-Water-2.png",
  76664. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76665. * "rotated": true,
  76666. * "trimmed": true,
  76667. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76668. * "sourceSize": {"w":32,"h":32}
  76669. * @returns RawTexture of the frameMap
  76670. */
  76671. private _createFrameBuffer;
  76672. /**
  76673. * Creates the tileMap texture Buffer
  76674. * @param buffer normally and array of numbers, or a false to generate from scratch
  76675. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76676. * @returns RawTexture of the tileMap
  76677. */
  76678. private _createTileBuffer;
  76679. /**
  76680. * Modifies the data of the tileMaps
  76681. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76682. * @param pos is the iVector2 Coordinates of the Tile
  76683. * @param tile The SpriteIndex of the new Tile
  76684. */
  76685. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76686. /**
  76687. * Creates the animationMap texture Buffer
  76688. * @param buffer normally and array of numbers, or a false to generate from scratch
  76689. * @returns RawTexture of the animationMap
  76690. */
  76691. private _createTileAnimationBuffer;
  76692. /**
  76693. * Modifies the data of the animationMap
  76694. * @param cellID is the Index of the Sprite
  76695. * @param _frame is the target Animation frame
  76696. * @param toCell is the Target Index of the next frame of the animation
  76697. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76698. * @param speed is a global scalar of the time variable on the map.
  76699. */
  76700. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76701. /**
  76702. * Exports the .tilemaps file
  76703. */
  76704. saveTileMaps(): void;
  76705. /**
  76706. * Imports the .tilemaps file
  76707. * @param url of the .tilemaps file
  76708. */
  76709. loadTileMaps(url: string): void;
  76710. /**
  76711. * Release associated resources
  76712. */
  76713. dispose(): void;
  76714. }
  76715. }
  76716. declare module BABYLON {
  76717. /**
  76718. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76719. * @see https://doc.babylonjs.com/babylon101/sprites
  76720. */
  76721. export class SpritePackedManager extends SpriteManager {
  76722. /** defines the packed manager's name */
  76723. name: string;
  76724. /**
  76725. * Creates a new sprite manager from a packed sprite sheet
  76726. * @param name defines the manager's name
  76727. * @param imgUrl defines the sprite sheet url
  76728. * @param capacity defines the maximum allowed number of sprites
  76729. * @param scene defines the hosting scene
  76730. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76731. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76732. * @param samplingMode defines the smapling mode to use with spritesheet
  76733. * @param fromPacked set to true; do not alter
  76734. */
  76735. constructor(
  76736. /** defines the packed manager's name */
  76737. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76738. }
  76739. }
  76740. declare module BABYLON {
  76741. /**
  76742. * Defines the list of states available for a task inside a AssetsManager
  76743. */
  76744. export enum AssetTaskState {
  76745. /**
  76746. * Initialization
  76747. */
  76748. INIT = 0,
  76749. /**
  76750. * Running
  76751. */
  76752. RUNNING = 1,
  76753. /**
  76754. * Done
  76755. */
  76756. DONE = 2,
  76757. /**
  76758. * Error
  76759. */
  76760. ERROR = 3
  76761. }
  76762. /**
  76763. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76764. */
  76765. export abstract class AbstractAssetTask {
  76766. /**
  76767. * Task name
  76768. */ name: string;
  76769. /**
  76770. * Callback called when the task is successful
  76771. */
  76772. onSuccess: (task: any) => void;
  76773. /**
  76774. * Callback called when the task is not successful
  76775. */
  76776. onError: (task: any, message?: string, exception?: any) => void;
  76777. /**
  76778. * Creates a new AssetsManager
  76779. * @param name defines the name of the task
  76780. */
  76781. constructor(
  76782. /**
  76783. * Task name
  76784. */ name: string);
  76785. private _isCompleted;
  76786. private _taskState;
  76787. private _errorObject;
  76788. /**
  76789. * Get if the task is completed
  76790. */
  76791. get isCompleted(): boolean;
  76792. /**
  76793. * Gets the current state of the task
  76794. */
  76795. get taskState(): AssetTaskState;
  76796. /**
  76797. * Gets the current error object (if task is in error)
  76798. */
  76799. get errorObject(): {
  76800. message?: string;
  76801. exception?: any;
  76802. };
  76803. /**
  76804. * Internal only
  76805. * @hidden
  76806. */
  76807. _setErrorObject(message?: string, exception?: any): void;
  76808. /**
  76809. * Execute the current task
  76810. * @param scene defines the scene where you want your assets to be loaded
  76811. * @param onSuccess is a callback called when the task is successfully executed
  76812. * @param onError is a callback called if an error occurs
  76813. */
  76814. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76815. /**
  76816. * Execute the current task
  76817. * @param scene defines the scene where you want your assets to be loaded
  76818. * @param onSuccess is a callback called when the task is successfully executed
  76819. * @param onError is a callback called if an error occurs
  76820. */
  76821. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76822. /**
  76823. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76824. * This can be used with failed tasks that have the reason for failure fixed.
  76825. */
  76826. reset(): void;
  76827. private onErrorCallback;
  76828. private onDoneCallback;
  76829. }
  76830. /**
  76831. * Define the interface used by progress events raised during assets loading
  76832. */
  76833. export interface IAssetsProgressEvent {
  76834. /**
  76835. * Defines the number of remaining tasks to process
  76836. */
  76837. remainingCount: number;
  76838. /**
  76839. * Defines the total number of tasks
  76840. */
  76841. totalCount: number;
  76842. /**
  76843. * Defines the task that was just processed
  76844. */
  76845. task: AbstractAssetTask;
  76846. }
  76847. /**
  76848. * Class used to share progress information about assets loading
  76849. */
  76850. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76851. /**
  76852. * Defines the number of remaining tasks to process
  76853. */
  76854. remainingCount: number;
  76855. /**
  76856. * Defines the total number of tasks
  76857. */
  76858. totalCount: number;
  76859. /**
  76860. * Defines the task that was just processed
  76861. */
  76862. task: AbstractAssetTask;
  76863. /**
  76864. * Creates a AssetsProgressEvent
  76865. * @param remainingCount defines the number of remaining tasks to process
  76866. * @param totalCount defines the total number of tasks
  76867. * @param task defines the task that was just processed
  76868. */
  76869. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76870. }
  76871. /**
  76872. * Define a task used by AssetsManager to load assets into a container
  76873. */
  76874. export class ContainerAssetTask extends AbstractAssetTask {
  76875. /**
  76876. * Defines the name of the task
  76877. */
  76878. name: string;
  76879. /**
  76880. * Defines the list of mesh's names you want to load
  76881. */
  76882. meshesNames: any;
  76883. /**
  76884. * Defines the root url to use as a base to load your meshes and associated resources
  76885. */
  76886. rootUrl: string;
  76887. /**
  76888. * Defines the filename or File of the scene to load from
  76889. */
  76890. sceneFilename: string | File;
  76891. /**
  76892. * Get the loaded asset container
  76893. */
  76894. loadedContainer: AssetContainer;
  76895. /**
  76896. * Gets the list of loaded meshes
  76897. */
  76898. loadedMeshes: Array<AbstractMesh>;
  76899. /**
  76900. * Gets the list of loaded particle systems
  76901. */
  76902. loadedParticleSystems: Array<IParticleSystem>;
  76903. /**
  76904. * Gets the list of loaded skeletons
  76905. */
  76906. loadedSkeletons: Array<Skeleton>;
  76907. /**
  76908. * Gets the list of loaded animation groups
  76909. */
  76910. loadedAnimationGroups: Array<AnimationGroup>;
  76911. /**
  76912. * Callback called when the task is successful
  76913. */
  76914. onSuccess: (task: ContainerAssetTask) => void;
  76915. /**
  76916. * Callback called when the task is successful
  76917. */
  76918. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76919. /**
  76920. * Creates a new ContainerAssetTask
  76921. * @param name defines the name of the task
  76922. * @param meshesNames defines the list of mesh's names you want to load
  76923. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76924. * @param sceneFilename defines the filename or File of the scene to load from
  76925. */
  76926. constructor(
  76927. /**
  76928. * Defines the name of the task
  76929. */
  76930. name: string,
  76931. /**
  76932. * Defines the list of mesh's names you want to load
  76933. */
  76934. meshesNames: any,
  76935. /**
  76936. * Defines the root url to use as a base to load your meshes and associated resources
  76937. */
  76938. rootUrl: string,
  76939. /**
  76940. * Defines the filename or File of the scene to load from
  76941. */
  76942. sceneFilename: string | File);
  76943. /**
  76944. * Execute the current task
  76945. * @param scene defines the scene where you want your assets to be loaded
  76946. * @param onSuccess is a callback called when the task is successfully executed
  76947. * @param onError is a callback called if an error occurs
  76948. */
  76949. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76950. }
  76951. /**
  76952. * Define a task used by AssetsManager to load meshes
  76953. */
  76954. export class MeshAssetTask extends AbstractAssetTask {
  76955. /**
  76956. * Defines the name of the task
  76957. */
  76958. name: string;
  76959. /**
  76960. * Defines the list of mesh's names you want to load
  76961. */
  76962. meshesNames: any;
  76963. /**
  76964. * Defines the root url to use as a base to load your meshes and associated resources
  76965. */
  76966. rootUrl: string;
  76967. /**
  76968. * Defines the filename or File of the scene to load from
  76969. */
  76970. sceneFilename: string | File;
  76971. /**
  76972. * Gets the list of loaded meshes
  76973. */
  76974. loadedMeshes: Array<AbstractMesh>;
  76975. /**
  76976. * Gets the list of loaded particle systems
  76977. */
  76978. loadedParticleSystems: Array<IParticleSystem>;
  76979. /**
  76980. * Gets the list of loaded skeletons
  76981. */
  76982. loadedSkeletons: Array<Skeleton>;
  76983. /**
  76984. * Gets the list of loaded animation groups
  76985. */
  76986. loadedAnimationGroups: Array<AnimationGroup>;
  76987. /**
  76988. * Callback called when the task is successful
  76989. */
  76990. onSuccess: (task: MeshAssetTask) => void;
  76991. /**
  76992. * Callback called when the task is successful
  76993. */
  76994. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76995. /**
  76996. * Creates a new MeshAssetTask
  76997. * @param name defines the name of the task
  76998. * @param meshesNames defines the list of mesh's names you want to load
  76999. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77000. * @param sceneFilename defines the filename or File of the scene to load from
  77001. */
  77002. constructor(
  77003. /**
  77004. * Defines the name of the task
  77005. */
  77006. name: string,
  77007. /**
  77008. * Defines the list of mesh's names you want to load
  77009. */
  77010. meshesNames: any,
  77011. /**
  77012. * Defines the root url to use as a base to load your meshes and associated resources
  77013. */
  77014. rootUrl: string,
  77015. /**
  77016. * Defines the filename or File of the scene to load from
  77017. */
  77018. sceneFilename: string | File);
  77019. /**
  77020. * Execute the current task
  77021. * @param scene defines the scene where you want your assets to be loaded
  77022. * @param onSuccess is a callback called when the task is successfully executed
  77023. * @param onError is a callback called if an error occurs
  77024. */
  77025. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77026. }
  77027. /**
  77028. * Define a task used by AssetsManager to load text content
  77029. */
  77030. export class TextFileAssetTask extends AbstractAssetTask {
  77031. /**
  77032. * Defines the name of the task
  77033. */
  77034. name: string;
  77035. /**
  77036. * Defines the location of the file to load
  77037. */
  77038. url: string;
  77039. /**
  77040. * Gets the loaded text string
  77041. */
  77042. text: string;
  77043. /**
  77044. * Callback called when the task is successful
  77045. */
  77046. onSuccess: (task: TextFileAssetTask) => void;
  77047. /**
  77048. * Callback called when the task is successful
  77049. */
  77050. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77051. /**
  77052. * Creates a new TextFileAssetTask object
  77053. * @param name defines the name of the task
  77054. * @param url defines the location of the file to load
  77055. */
  77056. constructor(
  77057. /**
  77058. * Defines the name of the task
  77059. */
  77060. name: string,
  77061. /**
  77062. * Defines the location of the file to load
  77063. */
  77064. url: string);
  77065. /**
  77066. * Execute the current task
  77067. * @param scene defines the scene where you want your assets to be loaded
  77068. * @param onSuccess is a callback called when the task is successfully executed
  77069. * @param onError is a callback called if an error occurs
  77070. */
  77071. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77072. }
  77073. /**
  77074. * Define a task used by AssetsManager to load binary data
  77075. */
  77076. export class BinaryFileAssetTask extends AbstractAssetTask {
  77077. /**
  77078. * Defines the name of the task
  77079. */
  77080. name: string;
  77081. /**
  77082. * Defines the location of the file to load
  77083. */
  77084. url: string;
  77085. /**
  77086. * Gets the lodaded data (as an array buffer)
  77087. */
  77088. data: ArrayBuffer;
  77089. /**
  77090. * Callback called when the task is successful
  77091. */
  77092. onSuccess: (task: BinaryFileAssetTask) => void;
  77093. /**
  77094. * Callback called when the task is successful
  77095. */
  77096. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77097. /**
  77098. * Creates a new BinaryFileAssetTask object
  77099. * @param name defines the name of the new task
  77100. * @param url defines the location of the file to load
  77101. */
  77102. constructor(
  77103. /**
  77104. * Defines the name of the task
  77105. */
  77106. name: string,
  77107. /**
  77108. * Defines the location of the file to load
  77109. */
  77110. url: string);
  77111. /**
  77112. * Execute the current task
  77113. * @param scene defines the scene where you want your assets to be loaded
  77114. * @param onSuccess is a callback called when the task is successfully executed
  77115. * @param onError is a callback called if an error occurs
  77116. */
  77117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77118. }
  77119. /**
  77120. * Define a task used by AssetsManager to load images
  77121. */
  77122. export class ImageAssetTask extends AbstractAssetTask {
  77123. /**
  77124. * Defines the name of the task
  77125. */
  77126. name: string;
  77127. /**
  77128. * Defines the location of the image to load
  77129. */
  77130. url: string;
  77131. /**
  77132. * Gets the loaded images
  77133. */
  77134. image: HTMLImageElement;
  77135. /**
  77136. * Callback called when the task is successful
  77137. */
  77138. onSuccess: (task: ImageAssetTask) => void;
  77139. /**
  77140. * Callback called when the task is successful
  77141. */
  77142. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77143. /**
  77144. * Creates a new ImageAssetTask
  77145. * @param name defines the name of the task
  77146. * @param url defines the location of the image to load
  77147. */
  77148. constructor(
  77149. /**
  77150. * Defines the name of the task
  77151. */
  77152. name: string,
  77153. /**
  77154. * Defines the location of the image to load
  77155. */
  77156. url: string);
  77157. /**
  77158. * Execute the current task
  77159. * @param scene defines the scene where you want your assets to be loaded
  77160. * @param onSuccess is a callback called when the task is successfully executed
  77161. * @param onError is a callback called if an error occurs
  77162. */
  77163. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77164. }
  77165. /**
  77166. * Defines the interface used by texture loading tasks
  77167. */
  77168. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77169. /**
  77170. * Gets the loaded texture
  77171. */
  77172. texture: TEX;
  77173. }
  77174. /**
  77175. * Define a task used by AssetsManager to load 2D textures
  77176. */
  77177. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77178. /**
  77179. * Defines the name of the task
  77180. */
  77181. name: string;
  77182. /**
  77183. * Defines the location of the file to load
  77184. */
  77185. url: string;
  77186. /**
  77187. * Defines if mipmap should not be generated (default is false)
  77188. */
  77189. noMipmap?: boolean | undefined;
  77190. /**
  77191. * Defines if texture must be inverted on Y axis (default is true)
  77192. */
  77193. invertY: boolean;
  77194. /**
  77195. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77196. */
  77197. samplingMode: number;
  77198. /**
  77199. * Gets the loaded texture
  77200. */
  77201. texture: Texture;
  77202. /**
  77203. * Callback called when the task is successful
  77204. */
  77205. onSuccess: (task: TextureAssetTask) => void;
  77206. /**
  77207. * Callback called when the task is successful
  77208. */
  77209. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77210. /**
  77211. * Creates a new TextureAssetTask object
  77212. * @param name defines the name of the task
  77213. * @param url defines the location of the file to load
  77214. * @param noMipmap defines if mipmap should not be generated (default is false)
  77215. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77216. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77217. */
  77218. constructor(
  77219. /**
  77220. * Defines the name of the task
  77221. */
  77222. name: string,
  77223. /**
  77224. * Defines the location of the file to load
  77225. */
  77226. url: string,
  77227. /**
  77228. * Defines if mipmap should not be generated (default is false)
  77229. */
  77230. noMipmap?: boolean | undefined,
  77231. /**
  77232. * Defines if texture must be inverted on Y axis (default is true)
  77233. */
  77234. invertY?: boolean,
  77235. /**
  77236. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77237. */
  77238. samplingMode?: number);
  77239. /**
  77240. * Execute the current task
  77241. * @param scene defines the scene where you want your assets to be loaded
  77242. * @param onSuccess is a callback called when the task is successfully executed
  77243. * @param onError is a callback called if an error occurs
  77244. */
  77245. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77246. }
  77247. /**
  77248. * Define a task used by AssetsManager to load cube textures
  77249. */
  77250. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77251. /**
  77252. * Defines the name of the task
  77253. */
  77254. name: string;
  77255. /**
  77256. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77257. */
  77258. url: string;
  77259. /**
  77260. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77261. */
  77262. extensions?: string[] | undefined;
  77263. /**
  77264. * Defines if mipmaps should not be generated (default is false)
  77265. */
  77266. noMipmap?: boolean | undefined;
  77267. /**
  77268. * Defines the explicit list of files (undefined by default)
  77269. */
  77270. files?: string[] | undefined;
  77271. /**
  77272. * Gets the loaded texture
  77273. */
  77274. texture: CubeTexture;
  77275. /**
  77276. * Callback called when the task is successful
  77277. */
  77278. onSuccess: (task: CubeTextureAssetTask) => void;
  77279. /**
  77280. * Callback called when the task is successful
  77281. */
  77282. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77283. /**
  77284. * Creates a new CubeTextureAssetTask
  77285. * @param name defines the name of the task
  77286. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77287. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77288. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77289. * @param files defines the explicit list of files (undefined by default)
  77290. */
  77291. constructor(
  77292. /**
  77293. * Defines the name of the task
  77294. */
  77295. name: string,
  77296. /**
  77297. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77298. */
  77299. url: string,
  77300. /**
  77301. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77302. */
  77303. extensions?: string[] | undefined,
  77304. /**
  77305. * Defines if mipmaps should not be generated (default is false)
  77306. */
  77307. noMipmap?: boolean | undefined,
  77308. /**
  77309. * Defines the explicit list of files (undefined by default)
  77310. */
  77311. files?: string[] | undefined);
  77312. /**
  77313. * Execute the current task
  77314. * @param scene defines the scene where you want your assets to be loaded
  77315. * @param onSuccess is a callback called when the task is successfully executed
  77316. * @param onError is a callback called if an error occurs
  77317. */
  77318. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77319. }
  77320. /**
  77321. * Define a task used by AssetsManager to load HDR cube textures
  77322. */
  77323. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77324. /**
  77325. * Defines the name of the task
  77326. */
  77327. name: string;
  77328. /**
  77329. * Defines the location of the file to load
  77330. */
  77331. url: string;
  77332. /**
  77333. * Defines the desired size (the more it increases the longer the generation will be)
  77334. */
  77335. size: number;
  77336. /**
  77337. * Defines if mipmaps should not be generated (default is false)
  77338. */
  77339. noMipmap: boolean;
  77340. /**
  77341. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77342. */
  77343. generateHarmonics: boolean;
  77344. /**
  77345. * 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)
  77346. */
  77347. gammaSpace: boolean;
  77348. /**
  77349. * Internal Use Only
  77350. */
  77351. reserved: boolean;
  77352. /**
  77353. * Gets the loaded texture
  77354. */
  77355. texture: HDRCubeTexture;
  77356. /**
  77357. * Callback called when the task is successful
  77358. */
  77359. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77360. /**
  77361. * Callback called when the task is successful
  77362. */
  77363. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77364. /**
  77365. * Creates a new HDRCubeTextureAssetTask object
  77366. * @param name defines the name of the task
  77367. * @param url defines the location of the file to load
  77368. * @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.
  77369. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77370. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77371. * @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)
  77372. * @param reserved Internal use only
  77373. */
  77374. constructor(
  77375. /**
  77376. * Defines the name of the task
  77377. */
  77378. name: string,
  77379. /**
  77380. * Defines the location of the file to load
  77381. */
  77382. url: string,
  77383. /**
  77384. * Defines the desired size (the more it increases the longer the generation will be)
  77385. */
  77386. size: number,
  77387. /**
  77388. * Defines if mipmaps should not be generated (default is false)
  77389. */
  77390. noMipmap?: boolean,
  77391. /**
  77392. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77393. */
  77394. generateHarmonics?: boolean,
  77395. /**
  77396. * 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)
  77397. */
  77398. gammaSpace?: boolean,
  77399. /**
  77400. * Internal Use Only
  77401. */
  77402. reserved?: boolean);
  77403. /**
  77404. * Execute the current task
  77405. * @param scene defines the scene where you want your assets to be loaded
  77406. * @param onSuccess is a callback called when the task is successfully executed
  77407. * @param onError is a callback called if an error occurs
  77408. */
  77409. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77410. }
  77411. /**
  77412. * Define a task used by AssetsManager to load Equirectangular cube textures
  77413. */
  77414. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77415. /**
  77416. * Defines the name of the task
  77417. */
  77418. name: string;
  77419. /**
  77420. * Defines the location of the file to load
  77421. */
  77422. url: string;
  77423. /**
  77424. * Defines the desired size (the more it increases the longer the generation will be)
  77425. */
  77426. size: number;
  77427. /**
  77428. * Defines if mipmaps should not be generated (default is false)
  77429. */
  77430. noMipmap: boolean;
  77431. /**
  77432. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77433. * but the standard material would require them in Gamma space) (default is true)
  77434. */
  77435. gammaSpace: boolean;
  77436. /**
  77437. * Gets the loaded texture
  77438. */
  77439. texture: EquiRectangularCubeTexture;
  77440. /**
  77441. * Callback called when the task is successful
  77442. */
  77443. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77444. /**
  77445. * Callback called when the task is successful
  77446. */
  77447. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77448. /**
  77449. * Creates a new EquiRectangularCubeTextureAssetTask object
  77450. * @param name defines the name of the task
  77451. * @param url defines the location of the file to load
  77452. * @param size defines the desired size (the more it increases the longer the generation will be)
  77453. * If the size is omitted this implies you are using a preprocessed cubemap.
  77454. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77455. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77456. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77457. * (default is true)
  77458. */
  77459. constructor(
  77460. /**
  77461. * Defines the name of the task
  77462. */
  77463. name: string,
  77464. /**
  77465. * Defines the location of the file to load
  77466. */
  77467. url: string,
  77468. /**
  77469. * Defines the desired size (the more it increases the longer the generation will be)
  77470. */
  77471. size: number,
  77472. /**
  77473. * Defines if mipmaps should not be generated (default is false)
  77474. */
  77475. noMipmap?: boolean,
  77476. /**
  77477. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77478. * but the standard material would require them in Gamma space) (default is true)
  77479. */
  77480. gammaSpace?: boolean);
  77481. /**
  77482. * Execute the current task
  77483. * @param scene defines the scene where you want your assets to be loaded
  77484. * @param onSuccess is a callback called when the task is successfully executed
  77485. * @param onError is a callback called if an error occurs
  77486. */
  77487. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77488. }
  77489. /**
  77490. * This class can be used to easily import assets into a scene
  77491. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77492. */
  77493. export class AssetsManager {
  77494. private _scene;
  77495. private _isLoading;
  77496. protected _tasks: AbstractAssetTask[];
  77497. protected _waitingTasksCount: number;
  77498. protected _totalTasksCount: number;
  77499. /**
  77500. * Callback called when all tasks are processed
  77501. */
  77502. onFinish: (tasks: AbstractAssetTask[]) => void;
  77503. /**
  77504. * Callback called when a task is successful
  77505. */
  77506. onTaskSuccess: (task: AbstractAssetTask) => void;
  77507. /**
  77508. * Callback called when a task had an error
  77509. */
  77510. onTaskError: (task: AbstractAssetTask) => void;
  77511. /**
  77512. * Callback called when a task is done (whatever the result is)
  77513. */
  77514. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77515. /**
  77516. * Observable called when all tasks are processed
  77517. */
  77518. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77519. /**
  77520. * Observable called when a task had an error
  77521. */
  77522. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77523. /**
  77524. * Observable called when all tasks were executed
  77525. */
  77526. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77527. /**
  77528. * Observable called when a task is done (whatever the result is)
  77529. */
  77530. onProgressObservable: Observable<IAssetsProgressEvent>;
  77531. /**
  77532. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77533. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77534. */
  77535. useDefaultLoadingScreen: boolean;
  77536. /**
  77537. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77538. * when all assets have been downloaded.
  77539. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77540. */
  77541. autoHideLoadingUI: boolean;
  77542. /**
  77543. * Creates a new AssetsManager
  77544. * @param scene defines the scene to work on
  77545. */
  77546. constructor(scene: Scene);
  77547. /**
  77548. * Add a ContainerAssetTask to the list of active tasks
  77549. * @param taskName defines the name of the new task
  77550. * @param meshesNames defines the name of meshes to load
  77551. * @param rootUrl defines the root url to use to locate files
  77552. * @param sceneFilename defines the filename of the scene file
  77553. * @returns a new ContainerAssetTask object
  77554. */
  77555. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77556. /**
  77557. * Add a MeshAssetTask to the list of active tasks
  77558. * @param taskName defines the name of the new task
  77559. * @param meshesNames defines the name of meshes to load
  77560. * @param rootUrl defines the root url to use to locate files
  77561. * @param sceneFilename defines the filename of the scene file
  77562. * @returns a new MeshAssetTask object
  77563. */
  77564. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77565. /**
  77566. * Add a TextFileAssetTask to the list of active tasks
  77567. * @param taskName defines the name of the new task
  77568. * @param url defines the url of the file to load
  77569. * @returns a new TextFileAssetTask object
  77570. */
  77571. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77572. /**
  77573. * Add a BinaryFileAssetTask to the list of active tasks
  77574. * @param taskName defines the name of the new task
  77575. * @param url defines the url of the file to load
  77576. * @returns a new BinaryFileAssetTask object
  77577. */
  77578. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77579. /**
  77580. * Add a ImageAssetTask to the list of active tasks
  77581. * @param taskName defines the name of the new task
  77582. * @param url defines the url of the file to load
  77583. * @returns a new ImageAssetTask object
  77584. */
  77585. addImageTask(taskName: string, url: string): ImageAssetTask;
  77586. /**
  77587. * Add a TextureAssetTask to the list of active tasks
  77588. * @param taskName defines the name of the new task
  77589. * @param url defines the url of the file to load
  77590. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77591. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77592. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77593. * @returns a new TextureAssetTask object
  77594. */
  77595. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77596. /**
  77597. * Add a CubeTextureAssetTask 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. * @param extensions defines the extension to use to load the cube map (can be null)
  77601. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77602. * @param files defines the list of files to load (can be null)
  77603. * @returns a new CubeTextureAssetTask object
  77604. */
  77605. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77606. /**
  77607. *
  77608. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77609. * @param taskName defines the name of the new task
  77610. * @param url defines the url of the file to load
  77611. * @param size defines the size you want for the cubemap (can be null)
  77612. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77613. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77614. * @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)
  77615. * @param reserved Internal use only
  77616. * @returns a new HDRCubeTextureAssetTask object
  77617. */
  77618. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77619. /**
  77620. *
  77621. * Add a EquiRectangularCubeTextureAssetTask 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 size defines the size you want for the cubemap (can be null)
  77625. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77626. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77627. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77628. * @returns a new EquiRectangularCubeTextureAssetTask object
  77629. */
  77630. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77631. /**
  77632. * Remove a task from the assets manager.
  77633. * @param task the task to remove
  77634. */
  77635. removeTask(task: AbstractAssetTask): void;
  77636. private _decreaseWaitingTasksCount;
  77637. private _runTask;
  77638. /**
  77639. * Reset the AssetsManager and remove all tasks
  77640. * @return the current instance of the AssetsManager
  77641. */
  77642. reset(): AssetsManager;
  77643. /**
  77644. * Start the loading process
  77645. * @return the current instance of the AssetsManager
  77646. */
  77647. load(): AssetsManager;
  77648. /**
  77649. * Start the loading process as an async operation
  77650. * @return a promise returning the list of failed tasks
  77651. */
  77652. loadAsync(): Promise<void>;
  77653. }
  77654. }
  77655. declare module BABYLON {
  77656. /**
  77657. * Wrapper class for promise with external resolve and reject.
  77658. */
  77659. export class Deferred<T> {
  77660. /**
  77661. * The promise associated with this deferred object.
  77662. */
  77663. readonly promise: Promise<T>;
  77664. private _resolve;
  77665. private _reject;
  77666. /**
  77667. * The resolve method of the promise associated with this deferred object.
  77668. */
  77669. get resolve(): (value: T | PromiseLike<T>) => void;
  77670. /**
  77671. * The reject method of the promise associated with this deferred object.
  77672. */
  77673. get reject(): (reason?: any) => void;
  77674. /**
  77675. * Constructor for this deferred object.
  77676. */
  77677. constructor();
  77678. }
  77679. }
  77680. declare module BABYLON {
  77681. /**
  77682. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77683. */
  77684. export class MeshExploder {
  77685. private _centerMesh;
  77686. private _meshes;
  77687. private _meshesOrigins;
  77688. private _toCenterVectors;
  77689. private _scaledDirection;
  77690. private _newPosition;
  77691. private _centerPosition;
  77692. /**
  77693. * Explodes meshes from a center mesh.
  77694. * @param meshes The meshes to explode.
  77695. * @param centerMesh The mesh to be center of explosion.
  77696. */
  77697. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77698. private _setCenterMesh;
  77699. /**
  77700. * Get class name
  77701. * @returns "MeshExploder"
  77702. */
  77703. getClassName(): string;
  77704. /**
  77705. * "Exploded meshes"
  77706. * @returns Array of meshes with the centerMesh at index 0.
  77707. */
  77708. getMeshes(): Array<Mesh>;
  77709. /**
  77710. * Explodes meshes giving a specific direction
  77711. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77712. */
  77713. explode(direction?: number): void;
  77714. }
  77715. }
  77716. declare module BABYLON {
  77717. /**
  77718. * Class used to help managing file picking and drag'n'drop
  77719. */
  77720. export class FilesInput {
  77721. /**
  77722. * List of files ready to be loaded
  77723. */
  77724. static get FilesToLoad(): {
  77725. [key: string]: File;
  77726. };
  77727. /**
  77728. * Callback called when a file is processed
  77729. */
  77730. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  77731. /**
  77732. * Function used when loading the scene file
  77733. */
  77734. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  77735. private _engine;
  77736. private _currentScene;
  77737. private _sceneLoadedCallback;
  77738. private _progressCallback;
  77739. private _additionalRenderLoopLogicCallback;
  77740. private _textureLoadingCallback;
  77741. private _startingProcessingFilesCallback;
  77742. private _onReloadCallback;
  77743. private _errorCallback;
  77744. private _elementToMonitor;
  77745. private _sceneFileToLoad;
  77746. private _filesToLoad;
  77747. /**
  77748. * Creates a new FilesInput
  77749. * @param engine defines the rendering engine
  77750. * @param scene defines the hosting scene
  77751. * @param sceneLoadedCallback callback called when scene is loaded
  77752. * @param progressCallback callback called to track progress
  77753. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77754. * @param textureLoadingCallback callback called when a texture is loading
  77755. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77756. * @param onReloadCallback callback called when a reload is requested
  77757. * @param errorCallback callback call if an error occurs
  77758. */
  77759. 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>);
  77760. private _dragEnterHandler;
  77761. private _dragOverHandler;
  77762. private _dropHandler;
  77763. /**
  77764. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77765. * @param elementToMonitor defines the DOM element to track
  77766. */
  77767. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77768. /** Gets the current list of files to load */
  77769. get filesToLoad(): File[];
  77770. /**
  77771. * Release all associated resources
  77772. */
  77773. dispose(): void;
  77774. private renderFunction;
  77775. private drag;
  77776. private drop;
  77777. private _traverseFolder;
  77778. private _processFiles;
  77779. /**
  77780. * Load files from a drop event
  77781. * @param event defines the drop event to use as source
  77782. */
  77783. loadFiles(event: any): void;
  77784. private _processReload;
  77785. /**
  77786. * Reload the current scene from the loaded files
  77787. */
  77788. reload(): void;
  77789. }
  77790. }
  77791. declare module BABYLON {
  77792. /**
  77793. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77794. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77795. */
  77796. export class SceneOptimization {
  77797. /**
  77798. * Defines the priority of this optimization (0 by default which means first in the list)
  77799. */
  77800. priority: number;
  77801. /**
  77802. * Gets a string describing the action executed by the current optimization
  77803. * @returns description string
  77804. */
  77805. getDescription(): string;
  77806. /**
  77807. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77808. * @param scene defines the current scene where to apply this optimization
  77809. * @param optimizer defines the current optimizer
  77810. * @returns true if everything that can be done was applied
  77811. */
  77812. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77813. /**
  77814. * Creates the SceneOptimization object
  77815. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77816. * @param desc defines the description associated with the optimization
  77817. */
  77818. constructor(
  77819. /**
  77820. * Defines the priority of this optimization (0 by default which means first in the list)
  77821. */
  77822. priority?: number);
  77823. }
  77824. /**
  77825. * Defines an optimization used to reduce the size of render target textures
  77826. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77827. */
  77828. export class TextureOptimization extends SceneOptimization {
  77829. /**
  77830. * Defines the priority of this optimization (0 by default which means first in the list)
  77831. */
  77832. priority: number;
  77833. /**
  77834. * 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
  77835. */
  77836. maximumSize: number;
  77837. /**
  77838. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77839. */
  77840. step: number;
  77841. /**
  77842. * Gets a string describing the action executed by the current optimization
  77843. * @returns description string
  77844. */
  77845. getDescription(): string;
  77846. /**
  77847. * Creates the TextureOptimization object
  77848. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77849. * @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
  77850. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77851. */
  77852. constructor(
  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. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77867. * @param scene defines the current scene where to apply this optimization
  77868. * @param optimizer defines the current optimizer
  77869. * @returns true if everything that can be done was applied
  77870. */
  77871. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77872. }
  77873. /**
  77874. * Defines an optimization used to increase or decrease the rendering resolution
  77875. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77876. */
  77877. export class HardwareScalingOptimization extends SceneOptimization {
  77878. /**
  77879. * Defines the priority of this optimization (0 by default which means first in the list)
  77880. */
  77881. priority: number;
  77882. /**
  77883. * Defines the maximum scale to use (2 by default)
  77884. */
  77885. maximumScale: number;
  77886. /**
  77887. * Defines the step to use between two passes (0.5 by default)
  77888. */
  77889. step: number;
  77890. private _currentScale;
  77891. private _directionOffset;
  77892. /**
  77893. * Gets a string describing the action executed by the current optimization
  77894. * @return description string
  77895. */
  77896. getDescription(): string;
  77897. /**
  77898. * Creates the HardwareScalingOptimization object
  77899. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77900. * @param maximumScale defines the maximum scale to use (2 by default)
  77901. * @param step defines the step to use between two passes (0.5 by default)
  77902. */
  77903. constructor(
  77904. /**
  77905. * Defines the priority of this optimization (0 by default which means first in the list)
  77906. */
  77907. priority?: number,
  77908. /**
  77909. * Defines the maximum scale to use (2 by default)
  77910. */
  77911. maximumScale?: number,
  77912. /**
  77913. * Defines the step to use between two passes (0.5 by default)
  77914. */
  77915. step?: number);
  77916. /**
  77917. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77918. * @param scene defines the current scene where to apply this optimization
  77919. * @param optimizer defines the current optimizer
  77920. * @returns true if everything that can be done was applied
  77921. */
  77922. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77923. }
  77924. /**
  77925. * Defines an optimization used to remove shadows
  77926. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77927. */
  77928. export class ShadowsOptimization extends SceneOptimization {
  77929. /**
  77930. * Gets a string describing the action executed by the current optimization
  77931. * @return description string
  77932. */
  77933. getDescription(): string;
  77934. /**
  77935. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77936. * @param scene defines the current scene where to apply this optimization
  77937. * @param optimizer defines the current optimizer
  77938. * @returns true if everything that can be done was applied
  77939. */
  77940. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77941. }
  77942. /**
  77943. * Defines an optimization used to turn post-processes off
  77944. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77945. */
  77946. export class PostProcessesOptimization extends SceneOptimization {
  77947. /**
  77948. * Gets a string describing the action executed by the current optimization
  77949. * @return description string
  77950. */
  77951. getDescription(): string;
  77952. /**
  77953. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77954. * @param scene defines the current scene where to apply this optimization
  77955. * @param optimizer defines the current optimizer
  77956. * @returns true if everything that can be done was applied
  77957. */
  77958. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77959. }
  77960. /**
  77961. * Defines an optimization used to turn lens flares off
  77962. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77963. */
  77964. export class LensFlaresOptimization extends SceneOptimization {
  77965. /**
  77966. * Gets a string describing the action executed by the current optimization
  77967. * @return description string
  77968. */
  77969. getDescription(): string;
  77970. /**
  77971. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77972. * @param scene defines the current scene where to apply this optimization
  77973. * @param optimizer defines the current optimizer
  77974. * @returns true if everything that can be done was applied
  77975. */
  77976. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77977. }
  77978. /**
  77979. * Defines an optimization based on user defined callback.
  77980. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77981. */
  77982. export class CustomOptimization extends SceneOptimization {
  77983. /**
  77984. * Callback called to apply the custom optimization.
  77985. */
  77986. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77987. /**
  77988. * Callback called to get custom description
  77989. */
  77990. onGetDescription: () => string;
  77991. /**
  77992. * Gets a string describing the action executed by the current optimization
  77993. * @returns description string
  77994. */
  77995. getDescription(): string;
  77996. /**
  77997. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77998. * @param scene defines the current scene where to apply this optimization
  77999. * @param optimizer defines the current optimizer
  78000. * @returns true if everything that can be done was applied
  78001. */
  78002. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78003. }
  78004. /**
  78005. * Defines an optimization used to turn particles off
  78006. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78007. */
  78008. export class ParticlesOptimization extends SceneOptimization {
  78009. /**
  78010. * Gets a string describing the action executed by the current optimization
  78011. * @return description string
  78012. */
  78013. getDescription(): string;
  78014. /**
  78015. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78016. * @param scene defines the current scene where to apply this optimization
  78017. * @param optimizer defines the current optimizer
  78018. * @returns true if everything that can be done was applied
  78019. */
  78020. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78021. }
  78022. /**
  78023. * Defines an optimization used to turn render targets off
  78024. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78025. */
  78026. export class RenderTargetsOptimization extends SceneOptimization {
  78027. /**
  78028. * Gets a string describing the action executed by the current optimization
  78029. * @return description string
  78030. */
  78031. getDescription(): string;
  78032. /**
  78033. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78034. * @param scene defines the current scene where to apply this optimization
  78035. * @param optimizer defines the current optimizer
  78036. * @returns true if everything that can be done was applied
  78037. */
  78038. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78039. }
  78040. /**
  78041. * Defines an optimization used to merge meshes with compatible materials
  78042. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78043. */
  78044. export class MergeMeshesOptimization extends SceneOptimization {
  78045. private static _UpdateSelectionTree;
  78046. /**
  78047. * Gets or sets a boolean which defines if optimization octree has to be updated
  78048. */
  78049. static get UpdateSelectionTree(): boolean;
  78050. /**
  78051. * Gets or sets a boolean which defines if optimization octree has to be updated
  78052. */
  78053. static set UpdateSelectionTree(value: boolean);
  78054. /**
  78055. * Gets a string describing the action executed by the current optimization
  78056. * @return description string
  78057. */
  78058. getDescription(): string;
  78059. private _canBeMerged;
  78060. /**
  78061. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78062. * @param scene defines the current scene where to apply this optimization
  78063. * @param optimizer defines the current optimizer
  78064. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78065. * @returns true if everything that can be done was applied
  78066. */
  78067. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78068. }
  78069. /**
  78070. * Defines a list of options used by SceneOptimizer
  78071. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78072. */
  78073. export class SceneOptimizerOptions {
  78074. /**
  78075. * Defines the target frame rate to reach (60 by default)
  78076. */
  78077. targetFrameRate: number;
  78078. /**
  78079. * Defines the interval between two checkes (2000ms by default)
  78080. */
  78081. trackerDuration: number;
  78082. /**
  78083. * Gets the list of optimizations to apply
  78084. */
  78085. optimizations: SceneOptimization[];
  78086. /**
  78087. * Creates a new list of options used by SceneOptimizer
  78088. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78089. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78090. */
  78091. constructor(
  78092. /**
  78093. * Defines the target frame rate to reach (60 by default)
  78094. */
  78095. targetFrameRate?: number,
  78096. /**
  78097. * Defines the interval between two checkes (2000ms by default)
  78098. */
  78099. trackerDuration?: number);
  78100. /**
  78101. * Add a new optimization
  78102. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78103. * @returns the current SceneOptimizerOptions
  78104. */
  78105. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78106. /**
  78107. * Add a new custom optimization
  78108. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78109. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78110. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78111. * @returns the current SceneOptimizerOptions
  78112. */
  78113. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78114. /**
  78115. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78116. * @param targetFrameRate defines the target frame rate (60 by default)
  78117. * @returns a SceneOptimizerOptions object
  78118. */
  78119. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78120. /**
  78121. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78122. * @param targetFrameRate defines the target frame rate (60 by default)
  78123. * @returns a SceneOptimizerOptions object
  78124. */
  78125. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78126. /**
  78127. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78128. * @param targetFrameRate defines the target frame rate (60 by default)
  78129. * @returns a SceneOptimizerOptions object
  78130. */
  78131. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78132. }
  78133. /**
  78134. * Class used to run optimizations in order to reach a target frame rate
  78135. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78136. */
  78137. export class SceneOptimizer implements IDisposable {
  78138. private _isRunning;
  78139. private _options;
  78140. private _scene;
  78141. private _currentPriorityLevel;
  78142. private _targetFrameRate;
  78143. private _trackerDuration;
  78144. private _currentFrameRate;
  78145. private _sceneDisposeObserver;
  78146. private _improvementMode;
  78147. /**
  78148. * Defines an observable called when the optimizer reaches the target frame rate
  78149. */
  78150. onSuccessObservable: Observable<SceneOptimizer>;
  78151. /**
  78152. * Defines an observable called when the optimizer enables an optimization
  78153. */
  78154. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78155. /**
  78156. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78157. */
  78158. onFailureObservable: Observable<SceneOptimizer>;
  78159. /**
  78160. * Gets a boolean indicating if the optimizer is in improvement mode
  78161. */
  78162. get isInImprovementMode(): boolean;
  78163. /**
  78164. * Gets the current priority level (0 at start)
  78165. */
  78166. get currentPriorityLevel(): number;
  78167. /**
  78168. * Gets the current frame rate checked by the SceneOptimizer
  78169. */
  78170. get currentFrameRate(): number;
  78171. /**
  78172. * Gets or sets the current target frame rate (60 by default)
  78173. */
  78174. get targetFrameRate(): number;
  78175. /**
  78176. * Gets or sets the current target frame rate (60 by default)
  78177. */
  78178. set targetFrameRate(value: number);
  78179. /**
  78180. * Gets or sets the current interval between two checks (every 2000ms by default)
  78181. */
  78182. get trackerDuration(): number;
  78183. /**
  78184. * Gets or sets the current interval between two checks (every 2000ms by default)
  78185. */
  78186. set trackerDuration(value: number);
  78187. /**
  78188. * Gets the list of active optimizations
  78189. */
  78190. get optimizations(): SceneOptimization[];
  78191. /**
  78192. * Creates a new SceneOptimizer
  78193. * @param scene defines the scene to work on
  78194. * @param options defines the options to use with the SceneOptimizer
  78195. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78196. * @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)
  78197. */
  78198. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78199. /**
  78200. * Stops the current optimizer
  78201. */
  78202. stop(): void;
  78203. /**
  78204. * Reset the optimizer to initial step (current priority level = 0)
  78205. */
  78206. reset(): void;
  78207. /**
  78208. * Start the optimizer. By default it will try to reach a specific framerate
  78209. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78210. */
  78211. start(): void;
  78212. private _checkCurrentState;
  78213. /**
  78214. * Release all resources
  78215. */
  78216. dispose(): void;
  78217. /**
  78218. * Helper function to create a SceneOptimizer with one single line of code
  78219. * @param scene defines the scene to work on
  78220. * @param options defines the options to use with the SceneOptimizer
  78221. * @param onSuccess defines a callback to call on success
  78222. * @param onFailure defines a callback to call on failure
  78223. * @returns the new SceneOptimizer object
  78224. */
  78225. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78226. }
  78227. }
  78228. declare module BABYLON {
  78229. /**
  78230. * Class used to serialize a scene into a string
  78231. */
  78232. export class SceneSerializer {
  78233. /**
  78234. * Clear cache used by a previous serialization
  78235. */
  78236. static ClearCache(): void;
  78237. /**
  78238. * Serialize a scene into a JSON compatible object
  78239. * @param scene defines the scene to serialize
  78240. * @returns a JSON compatible object
  78241. */
  78242. static Serialize(scene: Scene): any;
  78243. /**
  78244. * Serialize a mesh into a JSON compatible object
  78245. * @param toSerialize defines the mesh to serialize
  78246. * @param withParents defines if parents must be serialized as well
  78247. * @param withChildren defines if children must be serialized as well
  78248. * @returns a JSON compatible object
  78249. */
  78250. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78251. }
  78252. }
  78253. declare module BABYLON {
  78254. /**
  78255. * This represents the different options available for the video capture.
  78256. */
  78257. export interface VideoRecorderOptions {
  78258. /** Defines the mime type of the video. */
  78259. mimeType: string;
  78260. /** Defines the FPS the video should be recorded at. */
  78261. fps: number;
  78262. /** Defines the chunk size for the recording data. */
  78263. recordChunckSize: number;
  78264. /** The audio tracks to attach to the recording. */
  78265. audioTracks?: MediaStreamTrack[];
  78266. }
  78267. /**
  78268. * This can help with recording videos from BabylonJS.
  78269. * This is based on the available WebRTC functionalities of the browser.
  78270. *
  78271. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78272. */
  78273. export class VideoRecorder {
  78274. private static readonly _defaultOptions;
  78275. /**
  78276. * Returns whether or not the VideoRecorder is available in your browser.
  78277. * @param engine Defines the Babylon Engine.
  78278. * @returns true if supported otherwise false.
  78279. */
  78280. static IsSupported(engine: Engine): boolean;
  78281. private readonly _options;
  78282. private _canvas;
  78283. private _mediaRecorder;
  78284. private _recordedChunks;
  78285. private _fileName;
  78286. private _resolve;
  78287. private _reject;
  78288. /**
  78289. * True when a recording is already in progress.
  78290. */
  78291. get isRecording(): boolean;
  78292. /**
  78293. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78294. * @param engine Defines the BabylonJS Engine you wish to record.
  78295. * @param options Defines options that can be used to customize the capture.
  78296. */
  78297. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78298. /**
  78299. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78300. */
  78301. stopRecording(): void;
  78302. /**
  78303. * Starts recording the canvas for a max duration specified in parameters.
  78304. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78305. * If null no automatic download will start and you can rely on the promise to get the data back.
  78306. * @param maxDuration Defines the maximum recording time in seconds.
  78307. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78308. * @return A promise callback at the end of the recording with the video data in Blob.
  78309. */
  78310. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78311. /**
  78312. * Releases internal resources used during the recording.
  78313. */
  78314. dispose(): void;
  78315. private _handleDataAvailable;
  78316. private _handleError;
  78317. private _handleStop;
  78318. }
  78319. }
  78320. declare module BABYLON {
  78321. /**
  78322. * Class containing a set of static utilities functions for screenshots
  78323. */
  78324. export class ScreenshotTools {
  78325. /**
  78326. * Captures a screenshot of the current rendering
  78327. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78328. * @param engine defines the rendering engine
  78329. * @param camera defines the source camera
  78330. * @param size This parameter can be set to a single number or to an object with the
  78331. * following (optional) properties: precision, width, height. If a single number is passed,
  78332. * it will be used for both width and height. If an object is passed, the screenshot size
  78333. * will be derived from the parameters. The precision property is a multiplier allowing
  78334. * rendering at a higher or lower resolution
  78335. * @param successCallback defines the callback receives a single parameter which contains the
  78336. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78337. * src parameter of an <img> to display it
  78338. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78339. * Check your browser for supported MIME types
  78340. */
  78341. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78342. /**
  78343. * Captures a screenshot of the current rendering
  78344. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78345. * @param engine defines the rendering engine
  78346. * @param camera defines the source camera
  78347. * @param size This parameter can be set to a single number or to an object with the
  78348. * following (optional) properties: precision, width, height. If a single number is passed,
  78349. * it will be used for both width and height. If an object is passed, the screenshot size
  78350. * will be derived from the parameters. The precision property is a multiplier allowing
  78351. * rendering at a higher or lower resolution
  78352. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78353. * Check your browser for supported MIME types
  78354. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78355. * to the src parameter of an <img> to display it
  78356. */
  78357. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78358. /**
  78359. * Generates an image screenshot from the specified camera.
  78360. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78361. * @param engine The engine to use for rendering
  78362. * @param camera The camera to use for rendering
  78363. * @param size This parameter can be set to a single number or to an object with the
  78364. * following (optional) properties: precision, width, height. If a single number is passed,
  78365. * it will be used for both width and height. If an object is passed, the screenshot size
  78366. * will be derived from the parameters. The precision property is a multiplier allowing
  78367. * rendering at a higher or lower resolution
  78368. * @param successCallback The callback receives a single parameter which contains the
  78369. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78370. * src parameter of an <img> to display it
  78371. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78372. * Check your browser for supported MIME types
  78373. * @param samples Texture samples (default: 1)
  78374. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78375. * @param fileName A name for for the downloaded file.
  78376. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78377. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78378. */
  78379. 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;
  78380. /**
  78381. * Generates an image screenshot from the specified camera.
  78382. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78383. * @param engine The engine to use for rendering
  78384. * @param camera The camera to use for rendering
  78385. * @param size This parameter can be set to a single number or to an object with the
  78386. * following (optional) properties: precision, width, height. If a single number is passed,
  78387. * it will be used for both width and height. If an object is passed, the screenshot size
  78388. * will be derived from the parameters. The precision property is a multiplier allowing
  78389. * rendering at a higher or lower resolution
  78390. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78391. * Check your browser for supported MIME types
  78392. * @param samples Texture samples (default: 1)
  78393. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78394. * @param fileName A name for for the downloaded file.
  78395. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78396. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78397. * to the src parameter of an <img> to display it
  78398. */
  78399. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78400. /**
  78401. * Gets height and width for screenshot size
  78402. * @private
  78403. */
  78404. private static _getScreenshotSize;
  78405. }
  78406. }
  78407. declare module BABYLON {
  78408. /**
  78409. * Interface for a data buffer
  78410. */
  78411. export interface IDataBuffer {
  78412. /**
  78413. * Reads bytes from the data buffer.
  78414. * @param byteOffset The byte offset to read
  78415. * @param byteLength The byte length to read
  78416. * @returns A promise that resolves when the bytes are read
  78417. */
  78418. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78419. /**
  78420. * The byte length of the buffer.
  78421. */
  78422. readonly byteLength: number;
  78423. }
  78424. /**
  78425. * Utility class for reading from a data buffer
  78426. */
  78427. export class DataReader {
  78428. /**
  78429. * The data buffer associated with this data reader.
  78430. */
  78431. readonly buffer: IDataBuffer;
  78432. /**
  78433. * The current byte offset from the beginning of the data buffer.
  78434. */
  78435. byteOffset: number;
  78436. private _dataView;
  78437. private _dataByteOffset;
  78438. /**
  78439. * Constructor
  78440. * @param buffer The buffer to read
  78441. */
  78442. constructor(buffer: IDataBuffer);
  78443. /**
  78444. * Loads the given byte length.
  78445. * @param byteLength The byte length to load
  78446. * @returns A promise that resolves when the load is complete
  78447. */
  78448. loadAsync(byteLength: number): Promise<void>;
  78449. /**
  78450. * Read a unsigned 32-bit integer from the currently loaded data range.
  78451. * @returns The 32-bit integer read
  78452. */
  78453. readUint32(): number;
  78454. /**
  78455. * Read a byte array from the currently loaded data range.
  78456. * @param byteLength The byte length to read
  78457. * @returns The byte array read
  78458. */
  78459. readUint8Array(byteLength: number): Uint8Array;
  78460. /**
  78461. * Read a string from the currently loaded data range.
  78462. * @param byteLength The byte length to read
  78463. * @returns The string read
  78464. */
  78465. readString(byteLength: number): string;
  78466. /**
  78467. * Skips the given byte length the currently loaded data range.
  78468. * @param byteLength The byte length to skip
  78469. */
  78470. skipBytes(byteLength: number): void;
  78471. }
  78472. }
  78473. declare module BABYLON {
  78474. /**
  78475. * Class for storing data to local storage if available or in-memory storage otherwise
  78476. */
  78477. export class DataStorage {
  78478. private static _Storage;
  78479. private static _GetStorage;
  78480. /**
  78481. * Reads a string from the data storage
  78482. * @param key The key to read
  78483. * @param defaultValue The value if the key doesn't exist
  78484. * @returns The string value
  78485. */
  78486. static ReadString(key: string, defaultValue: string): string;
  78487. /**
  78488. * Writes a string to the data storage
  78489. * @param key The key to write
  78490. * @param value The value to write
  78491. */
  78492. static WriteString(key: string, value: string): void;
  78493. /**
  78494. * Reads a boolean from the data storage
  78495. * @param key The key to read
  78496. * @param defaultValue The value if the key doesn't exist
  78497. * @returns The boolean value
  78498. */
  78499. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78500. /**
  78501. * Writes a boolean to the data storage
  78502. * @param key The key to write
  78503. * @param value The value to write
  78504. */
  78505. static WriteBoolean(key: string, value: boolean): void;
  78506. /**
  78507. * Reads a number from the data storage
  78508. * @param key The key to read
  78509. * @param defaultValue The value if the key doesn't exist
  78510. * @returns The number value
  78511. */
  78512. static ReadNumber(key: string, defaultValue: number): number;
  78513. /**
  78514. * Writes a number to the data storage
  78515. * @param key The key to write
  78516. * @param value The value to write
  78517. */
  78518. static WriteNumber(key: string, value: number): void;
  78519. }
  78520. }
  78521. declare module BABYLON {
  78522. /**
  78523. * Class used to record delta files between 2 scene states
  78524. */
  78525. export class SceneRecorder {
  78526. private _trackedScene;
  78527. private _savedJSON;
  78528. /**
  78529. * Track a given scene. This means the current scene state will be considered the original state
  78530. * @param scene defines the scene to track
  78531. */
  78532. track(scene: Scene): void;
  78533. /**
  78534. * Get the delta between current state and original state
  78535. * @returns a string containing the delta
  78536. */
  78537. getDelta(): any;
  78538. private _compareArray;
  78539. private _compareObjects;
  78540. private _compareCollections;
  78541. private static GetShadowGeneratorById;
  78542. /**
  78543. * Apply a given delta to a given scene
  78544. * @param deltaJSON defines the JSON containing the delta
  78545. * @param scene defines the scene to apply the delta to
  78546. */
  78547. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78548. private static _ApplyPropertiesToEntity;
  78549. private static _ApplyDeltaForEntity;
  78550. }
  78551. }
  78552. declare module BABYLON {
  78553. /**
  78554. * A 3D trajectory consisting of an order list of vectors describing a
  78555. * path of motion through 3D space.
  78556. */
  78557. export class Trajectory {
  78558. private _points;
  78559. private readonly _segmentLength;
  78560. /**
  78561. * Serialize to JSON.
  78562. * @returns serialized JSON string
  78563. */
  78564. serialize(): string;
  78565. /**
  78566. * Deserialize from JSON.
  78567. * @param json serialized JSON string
  78568. * @returns deserialized Trajectory
  78569. */
  78570. static Deserialize(json: string): Trajectory;
  78571. /**
  78572. * Create a new empty Trajectory.
  78573. * @param segmentLength radius of discretization for Trajectory points
  78574. */
  78575. constructor(segmentLength?: number);
  78576. /**
  78577. * Get the length of the Trajectory.
  78578. * @returns length of the Trajectory
  78579. */
  78580. getLength(): number;
  78581. /**
  78582. * Append a new point to the Trajectory.
  78583. * NOTE: This implementation has many allocations.
  78584. * @param point point to append to the Trajectory
  78585. */
  78586. add(point: DeepImmutable<Vector3>): void;
  78587. /**
  78588. * Create a new Trajectory with a segment length chosen to make it
  78589. * probable that the new Trajectory will have a specified number of
  78590. * segments. This operation is imprecise.
  78591. * @param targetResolution number of segments desired
  78592. * @returns new Trajectory with approximately the requested number of segments
  78593. */
  78594. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78595. /**
  78596. * Convert Trajectory segments into tokenized representation. This
  78597. * representation is an array of numbers where each nth number is the
  78598. * index of the token which is most similar to the nth segment of the
  78599. * Trajectory.
  78600. * @param tokens list of vectors which serve as discrete tokens
  78601. * @returns list of indices of most similar token per segment
  78602. */
  78603. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78604. private static _forwardDir;
  78605. private static _inverseFromVec;
  78606. private static _upDir;
  78607. private static _fromToVec;
  78608. private static _lookMatrix;
  78609. /**
  78610. * Transform the rotation (i.e., direction) of a segment to isolate
  78611. * the relative transformation represented by the segment. This operation
  78612. * may or may not succeed due to singularities in the equations that define
  78613. * motion relativity in this context.
  78614. * @param priorVec the origin of the prior segment
  78615. * @param fromVec the origin of the current segment
  78616. * @param toVec the destination of the current segment
  78617. * @param result reference to output variable
  78618. * @returns whether or not transformation was successful
  78619. */
  78620. private static _transformSegmentDirToRef;
  78621. private static _bestMatch;
  78622. private static _score;
  78623. private static _bestScore;
  78624. /**
  78625. * Determine which token vector is most similar to the
  78626. * segment vector.
  78627. * @param segment segment vector
  78628. * @param tokens token vector list
  78629. * @returns index of the most similar token to the segment
  78630. */
  78631. private static _tokenizeSegment;
  78632. }
  78633. /**
  78634. * Class representing a set of known, named trajectories to which Trajectories can be
  78635. * added and using which Trajectories can be recognized.
  78636. */
  78637. export class TrajectoryClassifier {
  78638. private _maximumAllowableMatchCost;
  78639. private _vector3Alphabet;
  78640. private _levenshteinAlphabet;
  78641. private _nameToDescribedTrajectory;
  78642. /**
  78643. * Serialize to JSON.
  78644. * @returns JSON serialization
  78645. */
  78646. serialize(): string;
  78647. /**
  78648. * Deserialize from JSON.
  78649. * @param json JSON serialization
  78650. * @returns deserialized TrajectorySet
  78651. */
  78652. static Deserialize(json: string): TrajectoryClassifier;
  78653. /**
  78654. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78655. * VERY naive, need to be generating these things from known
  78656. * sets. Better version later, probably eliminating this one.
  78657. * @returns auto-generated TrajectorySet
  78658. */
  78659. static Generate(): TrajectoryClassifier;
  78660. private constructor();
  78661. /**
  78662. * Add a new Trajectory to the set with a given name.
  78663. * @param trajectory new Trajectory to be added
  78664. * @param classification name to which to add the Trajectory
  78665. */
  78666. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78667. /**
  78668. * Remove a known named trajectory and all Trajectories associated with it.
  78669. * @param classification name to remove
  78670. * @returns whether anything was removed
  78671. */
  78672. deleteClassification(classification: string): boolean;
  78673. /**
  78674. * Attempt to recognize a Trajectory from among all the classifications
  78675. * already known to the classifier.
  78676. * @param trajectory Trajectory to be recognized
  78677. * @returns classification of Trajectory if recognized, null otherwise
  78678. */
  78679. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78680. }
  78681. }
  78682. declare module BABYLON {
  78683. /**
  78684. * An interface for all Hit test features
  78685. */
  78686. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78687. /**
  78688. * Triggered when new babylon (transformed) hit test results are available
  78689. */
  78690. onHitTestResultObservable: Observable<T[]>;
  78691. }
  78692. /**
  78693. * Options used for hit testing
  78694. */
  78695. export interface IWebXRLegacyHitTestOptions {
  78696. /**
  78697. * Only test when user interacted with the scene. Default - hit test every frame
  78698. */
  78699. testOnPointerDownOnly?: boolean;
  78700. /**
  78701. * The node to use to transform the local results to world coordinates
  78702. */
  78703. worldParentNode?: TransformNode;
  78704. }
  78705. /**
  78706. * Interface defining the babylon result of raycasting/hit-test
  78707. */
  78708. export interface IWebXRLegacyHitResult {
  78709. /**
  78710. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78711. */
  78712. transformationMatrix: Matrix;
  78713. /**
  78714. * The native hit test result
  78715. */
  78716. xrHitResult: XRHitResult | XRHitTestResult;
  78717. }
  78718. /**
  78719. * The currently-working hit-test module.
  78720. * Hit test (or Ray-casting) is used to interact with the real world.
  78721. * For further information read here - https://github.com/immersive-web/hit-test
  78722. */
  78723. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78724. /**
  78725. * options to use when constructing this feature
  78726. */
  78727. readonly options: IWebXRLegacyHitTestOptions;
  78728. private _direction;
  78729. private _mat;
  78730. private _onSelectEnabled;
  78731. private _origin;
  78732. /**
  78733. * The module's name
  78734. */
  78735. static readonly Name: string;
  78736. /**
  78737. * The (Babylon) version of this module.
  78738. * This is an integer representing the implementation version.
  78739. * This number does not correspond to the WebXR specs version
  78740. */
  78741. static readonly Version: number;
  78742. /**
  78743. * Populated with the last native XR Hit Results
  78744. */
  78745. lastNativeXRHitResults: XRHitResult[];
  78746. /**
  78747. * Triggered when new babylon (transformed) hit test results are available
  78748. */
  78749. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78750. /**
  78751. * Creates a new instance of the (legacy version) hit test feature
  78752. * @param _xrSessionManager an instance of WebXRSessionManager
  78753. * @param options options to use when constructing this feature
  78754. */
  78755. constructor(_xrSessionManager: WebXRSessionManager,
  78756. /**
  78757. * options to use when constructing this feature
  78758. */
  78759. options?: IWebXRLegacyHitTestOptions);
  78760. /**
  78761. * execute a hit test with an XR Ray
  78762. *
  78763. * @param xrSession a native xrSession that will execute this hit test
  78764. * @param xrRay the ray (position and direction) to use for ray-casting
  78765. * @param referenceSpace native XR reference space to use for the hit-test
  78766. * @param filter filter function that will filter the results
  78767. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78768. */
  78769. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78770. /**
  78771. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78772. * @param event the (select) event to use to select with
  78773. * @param referenceSpace the reference space to use for this hit test
  78774. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78775. */
  78776. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78777. /**
  78778. * attach this feature
  78779. * Will usually be called by the features manager
  78780. *
  78781. * @returns true if successful.
  78782. */
  78783. attach(): boolean;
  78784. /**
  78785. * detach this feature.
  78786. * Will usually be called by the features manager
  78787. *
  78788. * @returns true if successful.
  78789. */
  78790. detach(): boolean;
  78791. /**
  78792. * Dispose this feature and all of the resources attached
  78793. */
  78794. dispose(): void;
  78795. protected _onXRFrame(frame: XRFrame): void;
  78796. private _onHitTestResults;
  78797. private _onSelect;
  78798. }
  78799. }
  78800. declare module BABYLON {
  78801. /**
  78802. * Options used for hit testing (version 2)
  78803. */
  78804. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78805. /**
  78806. * Do not create a permanent hit test. Will usually be used when only
  78807. * transient inputs are needed.
  78808. */
  78809. disablePermanentHitTest?: boolean;
  78810. /**
  78811. * Enable transient (for example touch-based) hit test inspections
  78812. */
  78813. enableTransientHitTest?: boolean;
  78814. /**
  78815. * Offset ray for the permanent hit test
  78816. */
  78817. offsetRay?: Vector3;
  78818. /**
  78819. * Offset ray for the transient hit test
  78820. */
  78821. transientOffsetRay?: Vector3;
  78822. /**
  78823. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78824. */
  78825. useReferenceSpace?: boolean;
  78826. /**
  78827. * Override the default entity type(s) of the hit-test result
  78828. */
  78829. entityTypes?: XRHitTestTrackableType[];
  78830. }
  78831. /**
  78832. * Interface defining the babylon result of hit-test
  78833. */
  78834. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78835. /**
  78836. * The input source that generated this hit test (if transient)
  78837. */
  78838. inputSource?: XRInputSource;
  78839. /**
  78840. * Is this a transient hit test
  78841. */
  78842. isTransient?: boolean;
  78843. /**
  78844. * Position of the hit test result
  78845. */
  78846. position: Vector3;
  78847. /**
  78848. * Rotation of the hit test result
  78849. */
  78850. rotationQuaternion: Quaternion;
  78851. /**
  78852. * The native hit test result
  78853. */
  78854. xrHitResult: XRHitTestResult;
  78855. }
  78856. /**
  78857. * The currently-working hit-test module.
  78858. * Hit test (or Ray-casting) is used to interact with the real world.
  78859. * For further information read here - https://github.com/immersive-web/hit-test
  78860. *
  78861. * Tested on chrome (mobile) 80.
  78862. */
  78863. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78864. /**
  78865. * options to use when constructing this feature
  78866. */
  78867. readonly options: IWebXRHitTestOptions;
  78868. private _tmpMat;
  78869. private _tmpPos;
  78870. private _tmpQuat;
  78871. private _transientXrHitTestSource;
  78872. private _xrHitTestSource;
  78873. private initHitTestSource;
  78874. /**
  78875. * The module's name
  78876. */
  78877. static readonly Name: string;
  78878. /**
  78879. * The (Babylon) version of this module.
  78880. * This is an integer representing the implementation version.
  78881. * This number does not correspond to the WebXR specs version
  78882. */
  78883. static readonly Version: number;
  78884. /**
  78885. * When set to true, each hit test will have its own position/rotation objects
  78886. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78887. * the developers will clone them or copy them as they see fit.
  78888. */
  78889. autoCloneTransformation: boolean;
  78890. /**
  78891. * Triggered when new babylon (transformed) hit test results are available
  78892. * Note - this will be called when results come back from the device. It can be an empty array!!
  78893. */
  78894. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78895. /**
  78896. * Use this to temporarily pause hit test checks.
  78897. */
  78898. paused: boolean;
  78899. /**
  78900. * Creates a new instance of the hit test feature
  78901. * @param _xrSessionManager an instance of WebXRSessionManager
  78902. * @param options options to use when constructing this feature
  78903. */
  78904. constructor(_xrSessionManager: WebXRSessionManager,
  78905. /**
  78906. * options to use when constructing this feature
  78907. */
  78908. options?: IWebXRHitTestOptions);
  78909. /**
  78910. * attach this feature
  78911. * Will usually be called by the features manager
  78912. *
  78913. * @returns true if successful.
  78914. */
  78915. attach(): boolean;
  78916. /**
  78917. * detach this feature.
  78918. * Will usually be called by the features manager
  78919. *
  78920. * @returns true if successful.
  78921. */
  78922. detach(): boolean;
  78923. /**
  78924. * Dispose this feature and all of the resources attached
  78925. */
  78926. dispose(): void;
  78927. protected _onXRFrame(frame: XRFrame): void;
  78928. private _processWebXRHitTestResult;
  78929. }
  78930. }
  78931. declare module BABYLON {
  78932. /**
  78933. * Configuration options of the anchor system
  78934. */
  78935. export interface IWebXRAnchorSystemOptions {
  78936. /**
  78937. * a node that will be used to convert local to world coordinates
  78938. */
  78939. worldParentNode?: TransformNode;
  78940. /**
  78941. * If set to true a reference of the created anchors will be kept until the next session starts
  78942. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78943. */
  78944. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78945. }
  78946. /**
  78947. * A babylon container for an XR Anchor
  78948. */
  78949. export interface IWebXRAnchor {
  78950. /**
  78951. * A babylon-assigned ID for this anchor
  78952. */
  78953. id: number;
  78954. /**
  78955. * Transformation matrix to apply to an object attached to this anchor
  78956. */
  78957. transformationMatrix: Matrix;
  78958. /**
  78959. * The native anchor object
  78960. */
  78961. xrAnchor: XRAnchor;
  78962. /**
  78963. * if defined, this object will be constantly updated by the anchor's position and rotation
  78964. */
  78965. attachedNode?: TransformNode;
  78966. /**
  78967. * Remove this anchor from the scene
  78968. */
  78969. remove(): void;
  78970. }
  78971. /**
  78972. * An implementation of the anchor system for WebXR.
  78973. * For further information see https://github.com/immersive-web/anchors/
  78974. */
  78975. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78976. private _options;
  78977. private _lastFrameDetected;
  78978. private _trackedAnchors;
  78979. private _referenceSpaceForFrameAnchors;
  78980. private _futureAnchors;
  78981. /**
  78982. * The module's name
  78983. */
  78984. static readonly Name: string;
  78985. /**
  78986. * The (Babylon) version of this module.
  78987. * This is an integer representing the implementation version.
  78988. * This number does not correspond to the WebXR specs version
  78989. */
  78990. static readonly Version: number;
  78991. /**
  78992. * Observers registered here will be executed when a new anchor was added to the session
  78993. */
  78994. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78995. /**
  78996. * Observers registered here will be executed when an anchor was removed from the session
  78997. */
  78998. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78999. /**
  79000. * Observers registered here will be executed when an existing anchor updates
  79001. * This can execute N times every frame
  79002. */
  79003. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79004. /**
  79005. * Set the reference space to use for anchor creation, when not using a hit test.
  79006. * Will default to the session's reference space if not defined
  79007. */
  79008. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79009. /**
  79010. * constructs a new anchor system
  79011. * @param _xrSessionManager an instance of WebXRSessionManager
  79012. * @param _options configuration object for this feature
  79013. */
  79014. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79015. private _tmpVector;
  79016. private _tmpQuaternion;
  79017. private _populateTmpTransformation;
  79018. /**
  79019. * Create a new anchor point using a hit test result at a specific point in the scene
  79020. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79021. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79022. *
  79023. * @param hitTestResult The hit test result to use for this anchor creation
  79024. * @param position an optional position offset for this anchor
  79025. * @param rotationQuaternion an optional rotation offset for this anchor
  79026. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79027. */
  79028. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  79029. /**
  79030. * Add a new anchor at a specific position and rotation
  79031. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79032. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79033. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79034. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79035. *
  79036. * @param position the position in which to add an anchor
  79037. * @param rotationQuaternion an optional rotation for the anchor transformation
  79038. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79039. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79040. */
  79041. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  79042. /**
  79043. * Get the list of anchors currently being tracked by the system
  79044. */
  79045. get anchors(): IWebXRAnchor[];
  79046. /**
  79047. * detach this feature.
  79048. * Will usually be called by the features manager
  79049. *
  79050. * @returns true if successful.
  79051. */
  79052. detach(): boolean;
  79053. /**
  79054. * Dispose this feature and all of the resources attached
  79055. */
  79056. dispose(): void;
  79057. protected _onXRFrame(frame: XRFrame): void;
  79058. /**
  79059. * avoiding using Array.find for global support.
  79060. * @param xrAnchor the plane to find in the array
  79061. */
  79062. private _findIndexInAnchorArray;
  79063. private _updateAnchorWithXRFrame;
  79064. private _createAnchorAtTransformation;
  79065. }
  79066. }
  79067. declare module BABYLON {
  79068. /**
  79069. * Options used in the plane detector module
  79070. */
  79071. export interface IWebXRPlaneDetectorOptions {
  79072. /**
  79073. * The node to use to transform the local results to world coordinates
  79074. */
  79075. worldParentNode?: TransformNode;
  79076. /**
  79077. * If set to true a reference of the created planes will be kept until the next session starts
  79078. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79079. */
  79080. doNotRemovePlanesOnSessionEnded?: boolean;
  79081. /**
  79082. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79083. */
  79084. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79085. }
  79086. /**
  79087. * A babylon interface for a WebXR plane.
  79088. * A Plane is actually a polygon, built from N points in space
  79089. *
  79090. * Supported in chrome 79, not supported in canary 81 ATM
  79091. */
  79092. export interface IWebXRPlane {
  79093. /**
  79094. * a babylon-assigned ID for this polygon
  79095. */
  79096. id: number;
  79097. /**
  79098. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79099. */
  79100. polygonDefinition: Array<Vector3>;
  79101. /**
  79102. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79103. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79104. */
  79105. transformationMatrix: Matrix;
  79106. /**
  79107. * the native xr-plane object
  79108. */
  79109. xrPlane: XRPlane;
  79110. }
  79111. /**
  79112. * The plane detector is used to detect planes in the real world when in AR
  79113. * For more information see https://github.com/immersive-web/real-world-geometry/
  79114. */
  79115. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79116. private _options;
  79117. private _detectedPlanes;
  79118. private _enabled;
  79119. private _lastFrameDetected;
  79120. /**
  79121. * The module's name
  79122. */
  79123. static readonly Name: string;
  79124. /**
  79125. * The (Babylon) version of this module.
  79126. * This is an integer representing the implementation version.
  79127. * This number does not correspond to the WebXR specs version
  79128. */
  79129. static readonly Version: number;
  79130. /**
  79131. * Observers registered here will be executed when a new plane was added to the session
  79132. */
  79133. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79134. /**
  79135. * Observers registered here will be executed when a plane is no longer detected in the session
  79136. */
  79137. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79138. /**
  79139. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79140. * This can execute N times every frame
  79141. */
  79142. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79143. /**
  79144. * construct a new Plane Detector
  79145. * @param _xrSessionManager an instance of xr Session manager
  79146. * @param _options configuration to use when constructing this feature
  79147. */
  79148. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79149. /**
  79150. * detach this feature.
  79151. * Will usually be called by the features manager
  79152. *
  79153. * @returns true if successful.
  79154. */
  79155. detach(): boolean;
  79156. /**
  79157. * Dispose this feature and all of the resources attached
  79158. */
  79159. dispose(): void;
  79160. /**
  79161. * Check if the needed objects are defined.
  79162. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79163. */
  79164. isCompatible(): boolean;
  79165. protected _onXRFrame(frame: XRFrame): void;
  79166. private _init;
  79167. private _updatePlaneWithXRPlane;
  79168. /**
  79169. * avoiding using Array.find for global support.
  79170. * @param xrPlane the plane to find in the array
  79171. */
  79172. private _findIndexInPlaneArray;
  79173. }
  79174. }
  79175. declare module BABYLON {
  79176. /**
  79177. * Options interface for the background remover plugin
  79178. */
  79179. export interface IWebXRBackgroundRemoverOptions {
  79180. /**
  79181. * Further background meshes to disable when entering AR
  79182. */
  79183. backgroundMeshes?: AbstractMesh[];
  79184. /**
  79185. * flags to configure the removal of the environment helper.
  79186. * If not set, the entire background will be removed. If set, flags should be set as well.
  79187. */
  79188. environmentHelperRemovalFlags?: {
  79189. /**
  79190. * Should the skybox be removed (default false)
  79191. */
  79192. skyBox?: boolean;
  79193. /**
  79194. * Should the ground be removed (default false)
  79195. */
  79196. ground?: boolean;
  79197. };
  79198. /**
  79199. * don't disable the environment helper
  79200. */
  79201. ignoreEnvironmentHelper?: boolean;
  79202. }
  79203. /**
  79204. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79205. */
  79206. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79207. /**
  79208. * read-only options to be used in this module
  79209. */
  79210. readonly options: IWebXRBackgroundRemoverOptions;
  79211. /**
  79212. * The module's name
  79213. */
  79214. static readonly Name: string;
  79215. /**
  79216. * The (Babylon) version of this module.
  79217. * This is an integer representing the implementation version.
  79218. * This number does not correspond to the WebXR specs version
  79219. */
  79220. static readonly Version: number;
  79221. /**
  79222. * registered observers will be triggered when the background state changes
  79223. */
  79224. onBackgroundStateChangedObservable: Observable<boolean>;
  79225. /**
  79226. * constructs a new background remover module
  79227. * @param _xrSessionManager the session manager for this module
  79228. * @param options read-only options to be used in this module
  79229. */
  79230. constructor(_xrSessionManager: WebXRSessionManager,
  79231. /**
  79232. * read-only options to be used in this module
  79233. */
  79234. options?: IWebXRBackgroundRemoverOptions);
  79235. /**
  79236. * attach this feature
  79237. * Will usually be called by the features manager
  79238. *
  79239. * @returns true if successful.
  79240. */
  79241. attach(): boolean;
  79242. /**
  79243. * detach this feature.
  79244. * Will usually be called by the features manager
  79245. *
  79246. * @returns true if successful.
  79247. */
  79248. detach(): boolean;
  79249. /**
  79250. * Dispose this feature and all of the resources attached
  79251. */
  79252. dispose(): void;
  79253. protected _onXRFrame(_xrFrame: XRFrame): void;
  79254. private _setBackgroundState;
  79255. }
  79256. }
  79257. declare module BABYLON {
  79258. /**
  79259. * Options for the controller physics feature
  79260. */
  79261. export class IWebXRControllerPhysicsOptions {
  79262. /**
  79263. * Should the headset get its own impostor
  79264. */
  79265. enableHeadsetImpostor?: boolean;
  79266. /**
  79267. * Optional parameters for the headset impostor
  79268. */
  79269. headsetImpostorParams?: {
  79270. /**
  79271. * The type of impostor to create. Default is sphere
  79272. */
  79273. impostorType: number;
  79274. /**
  79275. * the size of the impostor. Defaults to 10cm
  79276. */
  79277. impostorSize?: number | {
  79278. width: number;
  79279. height: number;
  79280. depth: number;
  79281. };
  79282. /**
  79283. * Friction definitions
  79284. */
  79285. friction?: number;
  79286. /**
  79287. * Restitution
  79288. */
  79289. restitution?: number;
  79290. };
  79291. /**
  79292. * The physics properties of the future impostors
  79293. */
  79294. physicsProperties?: {
  79295. /**
  79296. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79297. * Note that this requires a physics engine that supports mesh impostors!
  79298. */
  79299. useControllerMesh?: boolean;
  79300. /**
  79301. * The type of impostor to create. Default is sphere
  79302. */
  79303. impostorType?: number;
  79304. /**
  79305. * the size of the impostor. Defaults to 10cm
  79306. */
  79307. impostorSize?: number | {
  79308. width: number;
  79309. height: number;
  79310. depth: number;
  79311. };
  79312. /**
  79313. * Friction definitions
  79314. */
  79315. friction?: number;
  79316. /**
  79317. * Restitution
  79318. */
  79319. restitution?: number;
  79320. };
  79321. /**
  79322. * the xr input to use with this pointer selection
  79323. */
  79324. xrInput: WebXRInput;
  79325. }
  79326. /**
  79327. * Add physics impostor to your webxr controllers,
  79328. * including naive calculation of their linear and angular velocity
  79329. */
  79330. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79331. private readonly _options;
  79332. private _attachController;
  79333. private _controllers;
  79334. private _debugMode;
  79335. private _delta;
  79336. private _headsetImpostor?;
  79337. private _headsetMesh?;
  79338. private _lastTimestamp;
  79339. private _tmpQuaternion;
  79340. private _tmpVector;
  79341. /**
  79342. * The module's name
  79343. */
  79344. static readonly Name: string;
  79345. /**
  79346. * The (Babylon) version of this module.
  79347. * This is an integer representing the implementation version.
  79348. * This number does not correspond to the webxr specs version
  79349. */
  79350. static readonly Version: number;
  79351. /**
  79352. * Construct a new Controller Physics Feature
  79353. * @param _xrSessionManager the corresponding xr session manager
  79354. * @param _options options to create this feature with
  79355. */
  79356. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79357. /**
  79358. * @hidden
  79359. * enable debugging - will show console outputs and the impostor mesh
  79360. */
  79361. _enablePhysicsDebug(): void;
  79362. /**
  79363. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79364. * @param xrController the controller to add
  79365. */
  79366. addController(xrController: WebXRInputSource): void;
  79367. /**
  79368. * attach this feature
  79369. * Will usually be called by the features manager
  79370. *
  79371. * @returns true if successful.
  79372. */
  79373. attach(): boolean;
  79374. /**
  79375. * detach this feature.
  79376. * Will usually be called by the features manager
  79377. *
  79378. * @returns true if successful.
  79379. */
  79380. detach(): boolean;
  79381. /**
  79382. * Get the headset impostor, if enabled
  79383. * @returns the impostor
  79384. */
  79385. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79386. /**
  79387. * Get the physics impostor of a specific controller.
  79388. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79389. * @param controller the controller or the controller id of which to get the impostor
  79390. * @returns the impostor or null
  79391. */
  79392. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79393. /**
  79394. * Update the physics properties provided in the constructor
  79395. * @param newProperties the new properties object
  79396. */
  79397. setPhysicsProperties(newProperties: {
  79398. impostorType?: number;
  79399. impostorSize?: number | {
  79400. width: number;
  79401. height: number;
  79402. depth: number;
  79403. };
  79404. friction?: number;
  79405. restitution?: number;
  79406. }): void;
  79407. protected _onXRFrame(_xrFrame: any): void;
  79408. private _detachController;
  79409. }
  79410. }
  79411. declare module BABYLON {
  79412. /**
  79413. * A babylon interface for a "WebXR" feature point.
  79414. * Represents the position and confidence value of a given feature point.
  79415. */
  79416. export interface IWebXRFeaturePoint {
  79417. /**
  79418. * Represents the position of the feature point in world space.
  79419. */
  79420. position: Vector3;
  79421. /**
  79422. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79423. */
  79424. confidenceValue: number;
  79425. }
  79426. /**
  79427. * The feature point system is used to detect feature points from real world geometry.
  79428. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79429. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79430. */
  79431. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79432. private _enabled;
  79433. private _featurePointCloud;
  79434. /**
  79435. * The module's name
  79436. */
  79437. static readonly Name: string;
  79438. /**
  79439. * The (Babylon) version of this module.
  79440. * This is an integer representing the implementation version.
  79441. * This number does not correspond to the WebXR specs version
  79442. */
  79443. static readonly Version: number;
  79444. /**
  79445. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79446. * Will notify the observers about which feature points have been added.
  79447. */
  79448. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79449. /**
  79450. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79451. * Will notify the observers about which feature points have been updated.
  79452. */
  79453. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79454. /**
  79455. * The current feature point cloud maintained across frames.
  79456. */
  79457. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79458. /**
  79459. * construct the feature point system
  79460. * @param _xrSessionManager an instance of xr Session manager
  79461. */
  79462. constructor(_xrSessionManager: WebXRSessionManager);
  79463. /**
  79464. * Detach this feature.
  79465. * Will usually be called by the features manager
  79466. *
  79467. * @returns true if successful.
  79468. */
  79469. detach(): boolean;
  79470. /**
  79471. * Dispose this feature and all of the resources attached
  79472. */
  79473. dispose(): void;
  79474. /**
  79475. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79476. */
  79477. protected _onXRFrame(frame: XRFrame): void;
  79478. /**
  79479. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79480. */
  79481. private _init;
  79482. }
  79483. }
  79484. declare module BABYLON {
  79485. /**
  79486. * Configuration interface for the hand tracking feature
  79487. */
  79488. export interface IWebXRHandTrackingOptions {
  79489. /**
  79490. * The xrInput that will be used as source for new hands
  79491. */
  79492. xrInput: WebXRInput;
  79493. /**
  79494. * Configuration object for the joint meshes
  79495. */
  79496. jointMeshes?: {
  79497. /**
  79498. * Should the meshes created be invisible (defaults to false)
  79499. */
  79500. invisible?: boolean;
  79501. /**
  79502. * A source mesh to be used to create instances. Defaults to a sphere.
  79503. * This mesh will be the source for all other (25) meshes.
  79504. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79505. */
  79506. sourceMesh?: Mesh;
  79507. /**
  79508. * This function will be called after a mesh was created for a specific joint.
  79509. * Using this function you can either manipulate the instance or return a new mesh.
  79510. * When returning a new mesh the instance created before will be disposed
  79511. */
  79512. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  79513. /**
  79514. * Should the source mesh stay visible. Defaults to false
  79515. */
  79516. keepOriginalVisible?: boolean;
  79517. /**
  79518. * Scale factor for all instances (defaults to 2)
  79519. */
  79520. scaleFactor?: number;
  79521. /**
  79522. * Should each instance have its own physics impostor
  79523. */
  79524. enablePhysics?: boolean;
  79525. /**
  79526. * If enabled, override default physics properties
  79527. */
  79528. physicsProps?: {
  79529. friction?: number;
  79530. restitution?: number;
  79531. impostorType?: number;
  79532. };
  79533. /**
  79534. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  79535. */
  79536. disableDefaultHandMesh?: boolean;
  79537. /**
  79538. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  79539. */
  79540. handMeshes?: {
  79541. right: AbstractMesh;
  79542. left: AbstractMesh;
  79543. };
  79544. /**
  79545. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  79546. */
  79547. rigMapping?: {
  79548. right: string[];
  79549. left: string[];
  79550. };
  79551. };
  79552. }
  79553. /**
  79554. * Parts of the hands divided to writs and finger names
  79555. */
  79556. export const enum HandPart {
  79557. /**
  79558. * HandPart - Wrist
  79559. */
  79560. WRIST = "wrist",
  79561. /**
  79562. * HandPart - The THumb
  79563. */
  79564. THUMB = "thumb",
  79565. /**
  79566. * HandPart - Index finger
  79567. */
  79568. INDEX = "index",
  79569. /**
  79570. * HandPart - Middle finger
  79571. */
  79572. MIDDLE = "middle",
  79573. /**
  79574. * HandPart - Ring finger
  79575. */
  79576. RING = "ring",
  79577. /**
  79578. * HandPart - Little finger
  79579. */
  79580. LITTLE = "little"
  79581. }
  79582. /**
  79583. * Representing a single hand (with its corresponding native XRHand object)
  79584. */
  79585. export class WebXRHand implements IDisposable {
  79586. /** the controller to which the hand correlates */
  79587. readonly xrController: WebXRInputSource;
  79588. /** the meshes to be used to track the hand joints */
  79589. readonly trackedMeshes: AbstractMesh[];
  79590. private _handMesh?;
  79591. private _rigMapping?;
  79592. private _scene;
  79593. private _defaultHandMesh;
  79594. private _transformNodeMapping;
  79595. /**
  79596. * Hand-parts definition (key is HandPart)
  79597. */
  79598. handPartsDefinition: {
  79599. [key: string]: number[];
  79600. };
  79601. /**
  79602. * Observers will be triggered when the mesh for this hand was initialized.
  79603. */
  79604. onHandMeshReadyObservable: Observable<WebXRHand>;
  79605. /**
  79606. * Populate the HandPartsDefinition object.
  79607. * This is called as a side effect since certain browsers don't have XRHand defined.
  79608. */
  79609. private generateHandPartsDefinition;
  79610. /**
  79611. * Construct a new hand object
  79612. * @param xrController the controller to which the hand correlates
  79613. * @param trackedMeshes the meshes to be used to track the hand joints
  79614. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  79615. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  79616. * @param disableDefaultHandMesh should the default mesh creation be disabled
  79617. */
  79618. constructor(
  79619. /** the controller to which the hand correlates */
  79620. xrController: WebXRInputSource,
  79621. /** the meshes to be used to track the hand joints */
  79622. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  79623. /**
  79624. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  79625. */
  79626. get handMesh(): AbstractMesh | undefined;
  79627. /**
  79628. * Update this hand from the latest xr frame
  79629. * @param xrFrame xrFrame to update from
  79630. * @param referenceSpace The current viewer reference space
  79631. * @param scaleFactor optional scale factor for the meshes
  79632. */
  79633. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79634. /**
  79635. * Get meshes of part of the hand
  79636. * @param part the part of hand to get
  79637. * @returns An array of meshes that correlate to the hand part requested
  79638. */
  79639. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79640. /**
  79641. * Dispose this Hand object
  79642. */
  79643. dispose(): void;
  79644. private _generateDefaultHandMesh;
  79645. }
  79646. /**
  79647. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79648. */
  79649. export class WebXRHandTracking extends WebXRAbstractFeature {
  79650. /**
  79651. * options to use when constructing this feature
  79652. */
  79653. readonly options: IWebXRHandTrackingOptions;
  79654. private static _idCounter;
  79655. /**
  79656. * The module's name
  79657. */
  79658. static readonly Name: string;
  79659. /**
  79660. * The (Babylon) version of this module.
  79661. * This is an integer representing the implementation version.
  79662. * This number does not correspond to the WebXR specs version
  79663. */
  79664. static readonly Version: number;
  79665. /**
  79666. * This observable will notify registered observers when a new hand object was added and initialized
  79667. */
  79668. onHandAddedObservable: Observable<WebXRHand>;
  79669. /**
  79670. * This observable will notify its observers right before the hand object is disposed
  79671. */
  79672. onHandRemovedObservable: Observable<WebXRHand>;
  79673. private _hands;
  79674. /**
  79675. * Creates a new instance of the hit test feature
  79676. * @param _xrSessionManager an instance of WebXRSessionManager
  79677. * @param options options to use when constructing this feature
  79678. */
  79679. constructor(_xrSessionManager: WebXRSessionManager,
  79680. /**
  79681. * options to use when constructing this feature
  79682. */
  79683. options: IWebXRHandTrackingOptions);
  79684. /**
  79685. * Check if the needed objects are defined.
  79686. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79687. */
  79688. isCompatible(): boolean;
  79689. /**
  79690. * attach this feature
  79691. * Will usually be called by the features manager
  79692. *
  79693. * @returns true if successful.
  79694. */
  79695. attach(): boolean;
  79696. /**
  79697. * detach this feature.
  79698. * Will usually be called by the features manager
  79699. *
  79700. * @returns true if successful.
  79701. */
  79702. detach(): boolean;
  79703. /**
  79704. * Dispose this feature and all of the resources attached
  79705. */
  79706. dispose(): void;
  79707. /**
  79708. * Get the hand object according to the controller id
  79709. * @param controllerId the controller id to which we want to get the hand
  79710. * @returns null if not found or the WebXRHand object if found
  79711. */
  79712. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79713. /**
  79714. * Get a hand object according to the requested handedness
  79715. * @param handedness the handedness to request
  79716. * @returns null if not found or the WebXRHand object if found
  79717. */
  79718. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79719. protected _onXRFrame(_xrFrame: XRFrame): void;
  79720. private _attachHand;
  79721. private _detachHand;
  79722. }
  79723. }
  79724. declare module BABYLON {
  79725. /**
  79726. * Options used in the mesh detector module
  79727. */
  79728. export interface IWebXRMeshDetectorOptions {
  79729. /**
  79730. * The node to use to transform the local results to world coordinates
  79731. */
  79732. worldParentNode?: TransformNode;
  79733. /**
  79734. * If set to true a reference of the created meshes will be kept until the next session starts
  79735. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  79736. */
  79737. doNotRemoveMeshesOnSessionEnded?: boolean;
  79738. /**
  79739. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79740. */
  79741. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79742. /**
  79743. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  79744. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  79745. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  79746. */
  79747. convertCoordinateSystems?: boolean;
  79748. }
  79749. /**
  79750. * A babylon interface for a XR mesh's vertex data.
  79751. *
  79752. * Currently not supported by WebXR, available only with BabylonNative
  79753. */
  79754. export interface IWebXRVertexData {
  79755. /**
  79756. * A babylon-assigned ID for this mesh
  79757. */
  79758. id: number;
  79759. /**
  79760. * Data required for constructing a mesh in Babylon.js.
  79761. */
  79762. xrMesh: XRMesh;
  79763. /**
  79764. * The node to use to transform the local results to world coordinates.
  79765. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  79766. */
  79767. worldParentNode?: TransformNode;
  79768. /**
  79769. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  79770. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79771. */
  79772. positions?: Float32Array;
  79773. /**
  79774. * An array of indices in babylon space. right/left hand system is taken into account.
  79775. * Indices will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79776. */
  79777. indices?: Uint32Array;
  79778. /**
  79779. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  79780. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  79781. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  79782. */
  79783. normals?: Float32Array;
  79784. /**
  79785. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  79786. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  79787. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79788. */
  79789. transformationMatrix?: Matrix;
  79790. }
  79791. /**
  79792. * The mesh detector is used to detect meshes in the real world when in AR
  79793. */
  79794. export class WebXRMeshDetector extends WebXRAbstractFeature {
  79795. private _options;
  79796. private _detectedMeshes;
  79797. /**
  79798. * The module's name
  79799. */
  79800. static readonly Name: string;
  79801. /**
  79802. * The (Babylon) version of this module.
  79803. * This is an integer representing the implementation version.
  79804. * This number does not correspond to the WebXR specs version
  79805. */
  79806. static readonly Version: number;
  79807. /**
  79808. * Observers registered here will be executed when a new mesh was added to the session
  79809. */
  79810. onMeshAddedObservable: Observable<IWebXRVertexData>;
  79811. /**
  79812. * Observers registered here will be executed when a mesh is no longer detected in the session
  79813. */
  79814. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  79815. /**
  79816. * Observers registered here will be executed when an existing mesh updates
  79817. */
  79818. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  79819. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  79820. detach(): boolean;
  79821. dispose(): void;
  79822. protected _onXRFrame(frame: XRFrame): void;
  79823. private _init;
  79824. private _updateVertexDataWithXRMesh;
  79825. }
  79826. }
  79827. declare module BABYLON {
  79828. /**
  79829. * Options interface for the background remover plugin
  79830. */
  79831. export interface IWebXRImageTrackingOptions {
  79832. /**
  79833. * A required array with images to track
  79834. */
  79835. images: {
  79836. /**
  79837. * The source of the image. can be a URL or an image bitmap
  79838. */
  79839. src: string | ImageBitmap;
  79840. /**
  79841. * The estimated width in the real world (in meters)
  79842. */
  79843. estimatedRealWorldWidth: number;
  79844. }[];
  79845. }
  79846. /**
  79847. * An object representing an image tracked by the system
  79848. */
  79849. export interface IWebXRTrackedImage {
  79850. /**
  79851. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  79852. */
  79853. id: number;
  79854. /**
  79855. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  79856. */
  79857. emulated?: boolean;
  79858. /**
  79859. * Just in case it is needed - the image bitmap that is being tracked
  79860. */
  79861. originalBitmap: ImageBitmap;
  79862. /**
  79863. * The native XR result image tracking result, untouched
  79864. */
  79865. xrTrackingResult?: XRImageTrackingResult;
  79866. /**
  79867. * Width in real world (meters)
  79868. */
  79869. realWorldWidth?: number;
  79870. /**
  79871. * A transformation matrix of this current image in the current reference space.
  79872. */
  79873. transformationMatrix: Matrix;
  79874. /**
  79875. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  79876. */
  79877. ratio?: number;
  79878. }
  79879. /**
  79880. * Image tracking for immersive AR sessions.
  79881. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  79882. */
  79883. export class WebXRImageTracking extends WebXRAbstractFeature {
  79884. /**
  79885. * read-only options to be used in this module
  79886. */
  79887. readonly options: IWebXRImageTrackingOptions;
  79888. /**
  79889. * The module's name
  79890. */
  79891. static readonly Name: string;
  79892. /**
  79893. * The (Babylon) version of this module.
  79894. * This is an integer representing the implementation version.
  79895. * This number does not correspond to the WebXR specs version
  79896. */
  79897. static readonly Version: number;
  79898. /**
  79899. * This will be triggered if the underlying system deems an image untrackable.
  79900. * The index is the index of the image from the array used to initialize the feature.
  79901. */
  79902. onUntrackableImageFoundObservable: Observable<number>;
  79903. /**
  79904. * An image was deemed trackable, and the system will start tracking it.
  79905. */
  79906. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  79907. /**
  79908. * The image was found and its state was updated.
  79909. */
  79910. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  79911. private _trackedImages;
  79912. private _originalTrackingRequest;
  79913. /**
  79914. * constructs the image tracking feature
  79915. * @param _xrSessionManager the session manager for this module
  79916. * @param options read-only options to be used in this module
  79917. */
  79918. constructor(_xrSessionManager: WebXRSessionManager,
  79919. /**
  79920. * read-only options to be used in this module
  79921. */
  79922. options: IWebXRImageTrackingOptions);
  79923. /**
  79924. * attach this feature
  79925. * Will usually be called by the features manager
  79926. *
  79927. * @returns true if successful.
  79928. */
  79929. attach(): boolean;
  79930. /**
  79931. * detach this feature.
  79932. * Will usually be called by the features manager
  79933. *
  79934. * @returns true if successful.
  79935. */
  79936. detach(): boolean;
  79937. /**
  79938. * Check if the needed objects are defined.
  79939. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79940. */
  79941. isCompatible(): boolean;
  79942. /**
  79943. * Get a tracked image by its ID.
  79944. *
  79945. * @param id the id of the image to load (position in the init array)
  79946. * @returns a trackable image, if exists in this location
  79947. */
  79948. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  79949. /**
  79950. * Dispose this feature and all of the resources attached
  79951. */
  79952. dispose(): void;
  79953. /**
  79954. * Extends the session init object if needed
  79955. * @returns augmentation object fo the xr session init object.
  79956. */
  79957. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  79958. protected _onXRFrame(_xrFrame: XRFrame): void;
  79959. private _init;
  79960. }
  79961. }
  79962. declare module BABYLON {
  79963. /**
  79964. * The motion controller class for all microsoft mixed reality controllers
  79965. */
  79966. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79967. protected readonly _mapping: {
  79968. defaultButton: {
  79969. valueNodeName: string;
  79970. unpressedNodeName: string;
  79971. pressedNodeName: string;
  79972. };
  79973. defaultAxis: {
  79974. valueNodeName: string;
  79975. minNodeName: string;
  79976. maxNodeName: string;
  79977. };
  79978. buttons: {
  79979. "xr-standard-trigger": {
  79980. rootNodeName: string;
  79981. componentProperty: string;
  79982. states: string[];
  79983. };
  79984. "xr-standard-squeeze": {
  79985. rootNodeName: string;
  79986. componentProperty: string;
  79987. states: string[];
  79988. };
  79989. "xr-standard-touchpad": {
  79990. rootNodeName: string;
  79991. labelAnchorNodeName: string;
  79992. touchPointNodeName: string;
  79993. };
  79994. "xr-standard-thumbstick": {
  79995. rootNodeName: string;
  79996. componentProperty: string;
  79997. states: string[];
  79998. };
  79999. };
  80000. axes: {
  80001. "xr-standard-touchpad": {
  80002. "x-axis": {
  80003. rootNodeName: string;
  80004. };
  80005. "y-axis": {
  80006. rootNodeName: string;
  80007. };
  80008. };
  80009. "xr-standard-thumbstick": {
  80010. "x-axis": {
  80011. rootNodeName: string;
  80012. };
  80013. "y-axis": {
  80014. rootNodeName: string;
  80015. };
  80016. };
  80017. };
  80018. };
  80019. /**
  80020. * The base url used to load the left and right controller models
  80021. */
  80022. static MODEL_BASE_URL: string;
  80023. /**
  80024. * The name of the left controller model file
  80025. */
  80026. static MODEL_LEFT_FILENAME: string;
  80027. /**
  80028. * The name of the right controller model file
  80029. */
  80030. static MODEL_RIGHT_FILENAME: string;
  80031. profileId: string;
  80032. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80033. protected _getFilenameAndPath(): {
  80034. filename: string;
  80035. path: string;
  80036. };
  80037. protected _getModelLoadingConstraints(): boolean;
  80038. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80039. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80040. protected _updateModel(): void;
  80041. }
  80042. }
  80043. declare module BABYLON {
  80044. /**
  80045. * The motion controller class for oculus touch (quest, rift).
  80046. * This class supports legacy mapping as well the standard xr mapping
  80047. */
  80048. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80049. private _forceLegacyControllers;
  80050. private _modelRootNode;
  80051. /**
  80052. * The base url used to load the left and right controller models
  80053. */
  80054. static MODEL_BASE_URL: string;
  80055. /**
  80056. * The name of the left controller model file
  80057. */
  80058. static MODEL_LEFT_FILENAME: string;
  80059. /**
  80060. * The name of the right controller model file
  80061. */
  80062. static MODEL_RIGHT_FILENAME: string;
  80063. /**
  80064. * Base Url for the Quest controller model.
  80065. */
  80066. static QUEST_MODEL_BASE_URL: string;
  80067. profileId: string;
  80068. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80069. protected _getFilenameAndPath(): {
  80070. filename: string;
  80071. path: string;
  80072. };
  80073. protected _getModelLoadingConstraints(): boolean;
  80074. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80075. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80076. protected _updateModel(): void;
  80077. /**
  80078. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80079. * between the touch and touch 2.
  80080. */
  80081. private _isQuest;
  80082. }
  80083. }
  80084. declare module BABYLON {
  80085. /**
  80086. * The motion controller class for the standard HTC-Vive controllers
  80087. */
  80088. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80089. private _modelRootNode;
  80090. /**
  80091. * The base url used to load the left and right controller models
  80092. */
  80093. static MODEL_BASE_URL: string;
  80094. /**
  80095. * File name for the controller model.
  80096. */
  80097. static MODEL_FILENAME: string;
  80098. profileId: string;
  80099. /**
  80100. * Create a new Vive motion controller object
  80101. * @param scene the scene to use to create this controller
  80102. * @param gamepadObject the corresponding gamepad object
  80103. * @param handedness the handedness of the controller
  80104. */
  80105. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80106. protected _getFilenameAndPath(): {
  80107. filename: string;
  80108. path: string;
  80109. };
  80110. protected _getModelLoadingConstraints(): boolean;
  80111. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80112. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80113. protected _updateModel(): void;
  80114. }
  80115. }
  80116. declare module BABYLON {
  80117. /**
  80118. * A cursor which tracks a point on a path
  80119. */
  80120. export class PathCursor {
  80121. private path;
  80122. /**
  80123. * Stores path cursor callbacks for when an onchange event is triggered
  80124. */
  80125. private _onchange;
  80126. /**
  80127. * The value of the path cursor
  80128. */
  80129. value: number;
  80130. /**
  80131. * The animation array of the path cursor
  80132. */
  80133. animations: Animation[];
  80134. /**
  80135. * Initializes the path cursor
  80136. * @param path The path to track
  80137. */
  80138. constructor(path: Path2);
  80139. /**
  80140. * Gets the cursor point on the path
  80141. * @returns A point on the path cursor at the cursor location
  80142. */
  80143. getPoint(): Vector3;
  80144. /**
  80145. * Moves the cursor ahead by the step amount
  80146. * @param step The amount to move the cursor forward
  80147. * @returns This path cursor
  80148. */
  80149. moveAhead(step?: number): PathCursor;
  80150. /**
  80151. * Moves the cursor behind by the step amount
  80152. * @param step The amount to move the cursor back
  80153. * @returns This path cursor
  80154. */
  80155. moveBack(step?: number): PathCursor;
  80156. /**
  80157. * Moves the cursor by the step amount
  80158. * If the step amount is greater than one, an exception is thrown
  80159. * @param step The amount to move the cursor
  80160. * @returns This path cursor
  80161. */
  80162. move(step: number): PathCursor;
  80163. /**
  80164. * Ensures that the value is limited between zero and one
  80165. * @returns This path cursor
  80166. */
  80167. private ensureLimits;
  80168. /**
  80169. * Runs onchange callbacks on change (used by the animation engine)
  80170. * @returns This path cursor
  80171. */
  80172. private raiseOnChange;
  80173. /**
  80174. * Executes a function on change
  80175. * @param f A path cursor onchange callback
  80176. * @returns This path cursor
  80177. */
  80178. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80179. }
  80180. }
  80181. declare module BABYLON {
  80182. /** @hidden */
  80183. export var blurPixelShader: {
  80184. name: string;
  80185. shader: string;
  80186. };
  80187. }
  80188. declare module BABYLON {
  80189. /** @hidden */
  80190. export var pointCloudVertexDeclaration: {
  80191. name: string;
  80192. shader: string;
  80193. };
  80194. }
  80195. // Mixins
  80196. interface Window {
  80197. mozIndexedDB: IDBFactory;
  80198. webkitIndexedDB: IDBFactory;
  80199. msIndexedDB: IDBFactory;
  80200. webkitURL: typeof URL;
  80201. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80202. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80203. WebGLRenderingContext: WebGLRenderingContext;
  80204. MSGesture: MSGesture;
  80205. CANNON: any;
  80206. AudioContext: AudioContext;
  80207. webkitAudioContext: AudioContext;
  80208. PointerEvent: any;
  80209. Math: Math;
  80210. Uint8Array: Uint8ArrayConstructor;
  80211. Float32Array: Float32ArrayConstructor;
  80212. mozURL: typeof URL;
  80213. msURL: typeof URL;
  80214. VRFrameData: any; // WebVR, from specs 1.1
  80215. DracoDecoderModule: any;
  80216. setImmediate(handler: (...args: any[]) => void): number;
  80217. }
  80218. interface HTMLCanvasElement {
  80219. requestPointerLock(): void;
  80220. msRequestPointerLock?(): void;
  80221. mozRequestPointerLock?(): void;
  80222. webkitRequestPointerLock?(): void;
  80223. /** Track wether a record is in progress */
  80224. isRecording: boolean;
  80225. /** Capture Stream method defined by some browsers */
  80226. captureStream(fps?: number): MediaStream;
  80227. }
  80228. interface CanvasRenderingContext2D {
  80229. msImageSmoothingEnabled: boolean;
  80230. }
  80231. interface MouseEvent {
  80232. mozMovementX: number;
  80233. mozMovementY: number;
  80234. webkitMovementX: number;
  80235. webkitMovementY: number;
  80236. msMovementX: number;
  80237. msMovementY: number;
  80238. }
  80239. interface Navigator {
  80240. mozGetVRDevices: (any: any) => any;
  80241. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80242. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80243. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80244. webkitGetGamepads(): Gamepad[];
  80245. msGetGamepads(): Gamepad[];
  80246. webkitGamepads(): Gamepad[];
  80247. }
  80248. interface HTMLVideoElement {
  80249. mozSrcObject: any;
  80250. }
  80251. interface Math {
  80252. fround(x: number): number;
  80253. imul(a: number, b: number): number;
  80254. log2(x: number): number;
  80255. }
  80256. interface WebGLRenderingContext {
  80257. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80258. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80259. vertexAttribDivisor(index: number, divisor: number): void;
  80260. createVertexArray(): any;
  80261. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80262. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80263. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80264. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80265. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80266. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80267. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80268. // Queries
  80269. createQuery(): WebGLQuery;
  80270. deleteQuery(query: WebGLQuery): void;
  80271. beginQuery(target: number, query: WebGLQuery): void;
  80272. endQuery(target: number): void;
  80273. getQueryParameter(query: WebGLQuery, pname: number): any;
  80274. getQuery(target: number, pname: number): any;
  80275. MAX_SAMPLES: number;
  80276. RGBA8: number;
  80277. READ_FRAMEBUFFER: number;
  80278. DRAW_FRAMEBUFFER: number;
  80279. UNIFORM_BUFFER: number;
  80280. HALF_FLOAT_OES: number;
  80281. RGBA16F: number;
  80282. RGBA32F: number;
  80283. R32F: number;
  80284. RG32F: number;
  80285. RGB32F: number;
  80286. R16F: number;
  80287. RG16F: number;
  80288. RGB16F: number;
  80289. RED: number;
  80290. RG: number;
  80291. R8: number;
  80292. RG8: number;
  80293. UNSIGNED_INT_24_8: number;
  80294. DEPTH24_STENCIL8: number;
  80295. MIN: number;
  80296. MAX: number;
  80297. /* Multiple Render Targets */
  80298. drawBuffers(buffers: number[]): void;
  80299. readBuffer(src: number): void;
  80300. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  80301. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  80302. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  80303. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  80304. // Occlusion Query
  80305. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  80306. ANY_SAMPLES_PASSED: number;
  80307. QUERY_RESULT_AVAILABLE: number;
  80308. QUERY_RESULT: number;
  80309. }
  80310. interface WebGLProgram {
  80311. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  80312. }
  80313. interface EXT_disjoint_timer_query {
  80314. QUERY_COUNTER_BITS_EXT: number;
  80315. TIME_ELAPSED_EXT: number;
  80316. TIMESTAMP_EXT: number;
  80317. GPU_DISJOINT_EXT: number;
  80318. QUERY_RESULT_EXT: number;
  80319. QUERY_RESULT_AVAILABLE_EXT: number;
  80320. queryCounterEXT(query: WebGLQuery, target: number): void;
  80321. createQueryEXT(): WebGLQuery;
  80322. beginQueryEXT(target: number, query: WebGLQuery): void;
  80323. endQueryEXT(target: number): void;
  80324. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  80325. deleteQueryEXT(query: WebGLQuery): void;
  80326. }
  80327. interface WebGLUniformLocation {
  80328. _currentState: any;
  80329. }
  80330. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  80331. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  80332. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  80333. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  80334. interface WebGLRenderingContext {
  80335. readonly RASTERIZER_DISCARD: number;
  80336. readonly DEPTH_COMPONENT24: number;
  80337. readonly TEXTURE_3D: number;
  80338. readonly TEXTURE_2D_ARRAY: number;
  80339. readonly TEXTURE_COMPARE_FUNC: number;
  80340. readonly TEXTURE_COMPARE_MODE: number;
  80341. readonly COMPARE_REF_TO_TEXTURE: number;
  80342. readonly TEXTURE_WRAP_R: number;
  80343. readonly HALF_FLOAT: number;
  80344. readonly RGB8: number;
  80345. readonly RED_INTEGER: number;
  80346. readonly RG_INTEGER: number;
  80347. readonly RGB_INTEGER: number;
  80348. readonly RGBA_INTEGER: number;
  80349. readonly R8_SNORM: number;
  80350. readonly RG8_SNORM: number;
  80351. readonly RGB8_SNORM: number;
  80352. readonly RGBA8_SNORM: number;
  80353. readonly R8I: number;
  80354. readonly RG8I: number;
  80355. readonly RGB8I: number;
  80356. readonly RGBA8I: number;
  80357. readonly R8UI: number;
  80358. readonly RG8UI: number;
  80359. readonly RGB8UI: number;
  80360. readonly RGBA8UI: number;
  80361. readonly R16I: number;
  80362. readonly RG16I: number;
  80363. readonly RGB16I: number;
  80364. readonly RGBA16I: number;
  80365. readonly R16UI: number;
  80366. readonly RG16UI: number;
  80367. readonly RGB16UI: number;
  80368. readonly RGBA16UI: number;
  80369. readonly R32I: number;
  80370. readonly RG32I: number;
  80371. readonly RGB32I: number;
  80372. readonly RGBA32I: number;
  80373. readonly R32UI: number;
  80374. readonly RG32UI: number;
  80375. readonly RGB32UI: number;
  80376. readonly RGBA32UI: number;
  80377. readonly RGB10_A2UI: number;
  80378. readonly R11F_G11F_B10F: number;
  80379. readonly RGB9_E5: number;
  80380. readonly RGB10_A2: number;
  80381. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  80382. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  80383. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  80384. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80385. readonly DEPTH_COMPONENT32F: number;
  80386. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  80387. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  80388. 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;
  80389. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  80390. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  80391. readonly TRANSFORM_FEEDBACK: number;
  80392. readonly INTERLEAVED_ATTRIBS: number;
  80393. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  80394. createTransformFeedback(): WebGLTransformFeedback;
  80395. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  80396. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  80397. beginTransformFeedback(primitiveMode: number): void;
  80398. endTransformFeedback(): void;
  80399. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  80400. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80401. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80402. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80403. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  80404. }
  80405. interface ImageBitmap {
  80406. readonly width: number;
  80407. readonly height: number;
  80408. close(): void;
  80409. }
  80410. interface WebGLQuery extends WebGLObject {
  80411. }
  80412. declare var WebGLQuery: {
  80413. prototype: WebGLQuery;
  80414. new(): WebGLQuery;
  80415. };
  80416. interface WebGLSampler extends WebGLObject {
  80417. }
  80418. declare var WebGLSampler: {
  80419. prototype: WebGLSampler;
  80420. new(): WebGLSampler;
  80421. };
  80422. interface WebGLSync extends WebGLObject {
  80423. }
  80424. declare var WebGLSync: {
  80425. prototype: WebGLSync;
  80426. new(): WebGLSync;
  80427. };
  80428. interface WebGLTransformFeedback extends WebGLObject {
  80429. }
  80430. declare var WebGLTransformFeedback: {
  80431. prototype: WebGLTransformFeedback;
  80432. new(): WebGLTransformFeedback;
  80433. };
  80434. interface WebGLVertexArrayObject extends WebGLObject {
  80435. }
  80436. declare var WebGLVertexArrayObject: {
  80437. prototype: WebGLVertexArrayObject;
  80438. new(): WebGLVertexArrayObject;
  80439. };
  80440. interface Navigator {
  80441. readonly gpu: GPU | undefined;
  80442. }
  80443. interface GPUColorDict {
  80444. a: number;
  80445. b: number;
  80446. g: number;
  80447. r: number;
  80448. }
  80449. type GPUColor = [number, number, number, number] | GPUColorDict;
  80450. interface GPUOrigin2DDict {
  80451. x?: number;
  80452. y?: number;
  80453. }
  80454. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  80455. interface GPUOrigin3DDict {
  80456. x?: number;
  80457. y?: number;
  80458. z?: number;
  80459. }
  80460. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  80461. interface GPUExtent3DDict {
  80462. width: number;
  80463. height: number;
  80464. depth: number;
  80465. }
  80466. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  80467. type GPUBindingResource =
  80468. | GPUSampler
  80469. | GPUTextureView
  80470. | GPUBufferBinding;
  80471. type GPUExtensionName =
  80472. | "texture-compression-bc"
  80473. | "timestamp-query"
  80474. | "pipeline-statistics-query"
  80475. | "depth-clamping"
  80476. | "depth24unorm-stencil8"
  80477. | "depth32float-stencil8";
  80478. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  80479. type GPUBindingType =
  80480. | "uniform-buffer"
  80481. | "storage-buffer"
  80482. | "readonly-storage-buffer"
  80483. | "sampler"
  80484. | "comparison-sampler"
  80485. | "sampled-texture"
  80486. | "readonly-storage-texture"
  80487. | "writeonly-storage-texture";
  80488. type GPUBlendFactor =
  80489. | "zero"
  80490. | "one"
  80491. | "src-color"
  80492. | "one-minus-src-color"
  80493. | "src-alpha"
  80494. | "one-minus-src-alpha"
  80495. | "dst-color"
  80496. | "one-minus-dst-color"
  80497. | "dst-alpha"
  80498. | "one-minus-dst-alpha"
  80499. | "src-alpha-saturated"
  80500. | "blend-color"
  80501. | "one-minus-blend-color";
  80502. type GPUBlendOperation =
  80503. | "add"
  80504. | "subtract"
  80505. | "reverse-subtract"
  80506. | "min"
  80507. | "max";
  80508. type GPUCompareFunction =
  80509. | "never"
  80510. | "less"
  80511. | "equal"
  80512. | "less-equal"
  80513. | "greater"
  80514. | "not-equal"
  80515. | "greater-equal"
  80516. | "always";
  80517. type GPUCullMode = "none" | "front" | "back";
  80518. type GPUFilterMode = "nearest" | "linear";
  80519. type GPUFrontFace = "ccw" | "cw";
  80520. type GPUIndexFormat = "uint16" | "uint32";
  80521. type GPUInputStepMode = "vertex" | "instance";
  80522. type GPULoadOp = "load";
  80523. type GPUPrimitiveTopology =
  80524. | "point-list"
  80525. | "line-list"
  80526. | "line-strip"
  80527. | "triangle-list"
  80528. | "triangle-strip";
  80529. type GPUStencilOperation =
  80530. | "keep"
  80531. | "zero"
  80532. | "replace"
  80533. | "invert"
  80534. | "increment-clamp"
  80535. | "decrement-clamp"
  80536. | "increment-wrap"
  80537. | "decrement-wrap";
  80538. type GPUStoreOp = "store" | "clear";
  80539. type GPUTextureDimension = "1d" | "2d" | "3d";
  80540. type GPUTextureFormat =
  80541. | "r8unorm"
  80542. | "r8snorm"
  80543. | "r8uint"
  80544. | "r8sint"
  80545. | "r16uint"
  80546. | "r16sint"
  80547. | "r16float"
  80548. | "rg8unorm"
  80549. | "rg8snorm"
  80550. | "rg8uint"
  80551. | "rg8sint"
  80552. | "r32uint"
  80553. | "r32sint"
  80554. | "r32float"
  80555. | "rg16uint"
  80556. | "rg16sint"
  80557. | "rg16float"
  80558. | "rgba8unorm"
  80559. | "rgba8unorm-srgb"
  80560. | "rgba8snorm"
  80561. | "rgba8uint"
  80562. | "rgba8sint"
  80563. | "bgra8unorm"
  80564. | "bgra8unorm-srgb"
  80565. | "rgb9e5ufloat"
  80566. | "rgb10a2unorm"
  80567. | "rg11b10ufloat"
  80568. | "rg32uint"
  80569. | "rg32sint"
  80570. | "rg32float"
  80571. | "rgba16uint"
  80572. | "rgba16sint"
  80573. | "rgba16float"
  80574. | "rgba32uint"
  80575. | "rgba32sint"
  80576. | "rgba32float"
  80577. | "stencil8"
  80578. | "depth16unorm"
  80579. | "depth24plus"
  80580. | "depth24plus-stencil8"
  80581. | "depth32float"
  80582. | "bc1-rgba-unorm"
  80583. | "bc1-rgba-unorm-srgb"
  80584. | "bc2-rgba-unorm"
  80585. | "bc2-rgba-unorm-srgb"
  80586. | "bc3-rgba-unorm"
  80587. | "bc3-rgba-unorm-srgb"
  80588. | "bc4-r-unorm"
  80589. | "bc4-r-snorm"
  80590. | "bc5-rg-unorm"
  80591. | "bc5-rg-snorm"
  80592. | "bc6h-rgb-ufloat"
  80593. | "bc6h-rgb-float"
  80594. | "bc7-rgba-unorm"
  80595. | "bc7-rgba-unorm-srgb"
  80596. | "depth24unorm-stencil8"
  80597. | "depth32float-stencil8";
  80598. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  80599. type GPUTextureViewDimension =
  80600. | "1d"
  80601. | "2d"
  80602. | "2d-array"
  80603. | "cube"
  80604. | "cube-array"
  80605. | "3d";
  80606. type GPUVertexFormat =
  80607. | "uchar2"
  80608. | "uchar4"
  80609. | "char2"
  80610. | "char4"
  80611. | "uchar2norm"
  80612. | "uchar4norm"
  80613. | "char2norm"
  80614. | "char4norm"
  80615. | "ushort2"
  80616. | "ushort4"
  80617. | "short2"
  80618. | "short4"
  80619. | "ushort2norm"
  80620. | "ushort4norm"
  80621. | "short2norm"
  80622. | "short4norm"
  80623. | "half2"
  80624. | "half4"
  80625. | "float"
  80626. | "float2"
  80627. | "float3"
  80628. | "float4"
  80629. | "uint"
  80630. | "uint2"
  80631. | "uint3"
  80632. | "uint4"
  80633. | "int"
  80634. | "int2"
  80635. | "int3"
  80636. | "int4";
  80637. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  80638. type GPUBufferUsageFlags = number;
  80639. type GPUColorWriteFlags = number;
  80640. type GPUShaderStageFlags = number;
  80641. type GPUTextureUsageFlags = number;
  80642. type GPUMapModeFlags = number;
  80643. interface GPUBindGroupEntry {
  80644. binding: number;
  80645. resource: GPUBindingResource;
  80646. }
  80647. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  80648. layout: GPUBindGroupLayout;
  80649. entries: Iterable<GPUBindGroupEntry>;
  80650. }
  80651. interface GPUBindGroupLayoutEntry {
  80652. binding: number;
  80653. visibility: GPUShaderStageFlags;
  80654. type: GPUBindingType;
  80655. hasDynamicOffset?: boolean;
  80656. minBufferBindingSize?: number;
  80657. viewDimension?: GPUTextureViewDimension;
  80658. textureComponentType?: GPUTextureComponentType;
  80659. storageTextureFormat?: GPUTextureFormat;
  80660. }
  80661. interface GPUBindGroupLayoutDescriptor
  80662. extends GPUObjectDescriptorBase {
  80663. entries: Iterable<GPUBindGroupLayoutEntry>;
  80664. }
  80665. interface GPUBlendDescriptor {
  80666. dstFactor?: GPUBlendFactor;
  80667. operation?: GPUBlendOperation;
  80668. srcFactor?: GPUBlendFactor;
  80669. }
  80670. interface GPUColorStateDescriptor {
  80671. format: GPUTextureFormat;
  80672. alphaBlend?: GPUBlendDescriptor;
  80673. colorBlend?: GPUBlendDescriptor;
  80674. writeMask?: GPUColorWriteFlags;
  80675. }
  80676. interface GPUBufferBinding {
  80677. buffer: GPUBuffer;
  80678. offset?: number;
  80679. size?: number;
  80680. }
  80681. interface GPUTextureDataLayout {
  80682. offset?: number;
  80683. bytesPerRow: number;
  80684. rowsPerImage?: number;
  80685. }
  80686. interface GPUBufferCopyView extends GPUTextureDataLayout {
  80687. buffer: GPUBuffer;
  80688. }
  80689. interface GPUTextureCopyView {
  80690. texture: GPUTexture;
  80691. mipLevel?: number;
  80692. origin?: GPUOrigin3D;
  80693. }
  80694. interface GPUImageBitmapCopyView {
  80695. imageBitmap: ImageBitmap;
  80696. origin?: GPUOrigin2D;
  80697. }
  80698. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  80699. size: number;
  80700. usage: GPUBufferUsageFlags;
  80701. mappedAtCreation?: boolean;
  80702. }
  80703. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  80704. label?: string;
  80705. measureExecutionTime?: boolean;
  80706. }
  80707. interface GPUComputePipelineDescriptor
  80708. extends GPUPipelineDescriptorBase {
  80709. computeStage: GPUProgrammableStageDescriptor;
  80710. }
  80711. interface GPUDepthStencilStateDescriptor {
  80712. format: GPUTextureFormat;
  80713. depthWriteEnabled?: boolean;
  80714. depthCompare?: GPUCompareFunction;
  80715. stencilFront?: GPUStencilStateFaceDescriptor;
  80716. stencilBack?: GPUStencilStateFaceDescriptor;
  80717. stencilReadMask?: number;
  80718. stencilWriteMask?: number;
  80719. }
  80720. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  80721. extensions?: Iterable<GPUExtensionName>;
  80722. limits?: GPULimits;
  80723. }
  80724. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  80725. initialValue?: number;
  80726. label?: string;
  80727. signalQueue?: GPUQueue;
  80728. }
  80729. interface GPUVertexAttributeDescriptor {
  80730. format: GPUVertexFormat;
  80731. offset: number;
  80732. shaderLocation: number;
  80733. }
  80734. interface GPUVertexBufferLayoutDescriptor {
  80735. arrayStride: number;
  80736. stepMode?: GPUInputStepMode;
  80737. attributes: Iterable<GPUVertexAttributeDescriptor>;
  80738. }
  80739. interface GPUVertexStateDescriptor {
  80740. indexFormat?: GPUIndexFormat;
  80741. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  80742. }
  80743. interface GPULimits {
  80744. maxBindGroups?: number;
  80745. maxDynamicUniformBuffersPerPipelineLayout?: number;
  80746. maxDynamicStorageBuffersPerPipelineLayout?: number;
  80747. maxSampledTexturesPerShaderStage?: number;
  80748. maxSamplersPerShaderStage?: number;
  80749. maxStorageBuffersPerShaderStage?: number;
  80750. maxStorageTexturesPerShaderStage?: number;
  80751. maxUniformBuffersPerShaderStage?: number;
  80752. maxUniformBufferBindingSize?: number;
  80753. }
  80754. interface GPUPipelineDescriptorBase {
  80755. label?: string;
  80756. layout?: GPUPipelineLayout;
  80757. }
  80758. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  80759. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  80760. }
  80761. interface GPUProgrammableStageDescriptor {
  80762. module: GPUShaderModule;
  80763. entryPoint: string;
  80764. }
  80765. interface GPURasterizationStateDescriptor {
  80766. frontFace?: GPUFrontFace;
  80767. cullMode?: GPUCullMode;
  80768. clampDepth?: boolean;
  80769. depthBias?: number;
  80770. depthBiasSlopeScale?: number;
  80771. depthBiasClamp?: number;
  80772. }
  80773. interface GPURenderPassColorAttachmentDescriptor {
  80774. attachment: GPUTextureView;
  80775. resolveTarget?: GPUTextureView;
  80776. loadValue: GPULoadOp | GPUColor;
  80777. storeOp?: GPUStoreOp;
  80778. }
  80779. interface GPURenderPassDepthStencilAttachmentDescriptor {
  80780. attachment: GPUTextureView;
  80781. depthLoadValue: GPULoadOp | number;
  80782. depthStoreOp: GPUStoreOp;
  80783. depthReadOnly?: boolean;
  80784. stencilLoadValue: GPULoadOp | number;
  80785. stencilStoreOp: GPUStoreOp;
  80786. stencilReadOnly?: boolean;
  80787. }
  80788. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  80789. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  80790. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  80791. }
  80792. interface GPURenderPipelineDescriptor
  80793. extends GPUPipelineDescriptorBase {
  80794. vertexStage: GPUProgrammableStageDescriptor;
  80795. fragmentStage?: GPUProgrammableStageDescriptor;
  80796. primitiveTopology: GPUPrimitiveTopology;
  80797. rasterizationState?: GPURasterizationStateDescriptor;
  80798. colorStates: Iterable<GPUColorStateDescriptor>;
  80799. depthStencilState?: GPUDepthStencilStateDescriptor;
  80800. vertexState?: GPUVertexStateDescriptor;
  80801. sampleCount?: number;
  80802. sampleMask?: number;
  80803. alphaToCoverageEnabled?: boolean;
  80804. }
  80805. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  80806. addressModeU?: GPUAddressMode;
  80807. addressModeV?: GPUAddressMode;
  80808. addressModeW?: GPUAddressMode;
  80809. magFilter?: GPUFilterMode;
  80810. minFilter?: GPUFilterMode;
  80811. mipmapFilter?: GPUFilterMode;
  80812. lodMinClamp?: number;
  80813. lodMaxClamp?: number;
  80814. compare?: GPUCompareFunction;
  80815. maxAnisotropy?: number;
  80816. }
  80817. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  80818. code: Uint32Array | string;
  80819. label?: string;
  80820. sourceMap?: object;
  80821. }
  80822. interface GPUStencilStateFaceDescriptor {
  80823. compare?: GPUCompareFunction;
  80824. depthFailOp?: GPUStencilOperation;
  80825. passOp?: GPUStencilOperation;
  80826. failOp?: GPUStencilOperation;
  80827. }
  80828. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  80829. device: GPUDevice;
  80830. format: GPUTextureFormat;
  80831. usage?: GPUTextureUsageFlags;
  80832. }
  80833. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  80834. size: GPUExtent3D;
  80835. mipLevelCount?: number;
  80836. sampleCount?: number;
  80837. dimension?: GPUTextureDimension;
  80838. format: GPUTextureFormat;
  80839. usage: GPUTextureUsageFlags;
  80840. }
  80841. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  80842. format?: GPUTextureFormat;
  80843. dimension?: GPUTextureViewDimension;
  80844. aspect?: GPUTextureAspect;
  80845. baseArrayLayer?: number;
  80846. baseMipLevel?: number;
  80847. arrayLayerCount?: number;
  80848. mipLevelCount?: number;
  80849. }
  80850. declare class GPUAdapter {
  80851. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  80852. private __brand: void;
  80853. readonly name: string;
  80854. readonly extensions: GPUExtensionName[];
  80855. readonly limits: Required<GPULimits>;
  80856. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  80857. }
  80858. declare class GPUBindGroup implements GPUObjectBase {
  80859. private __brand: void;
  80860. label: string | undefined;
  80861. }
  80862. declare class GPUBindGroupLayout implements GPUObjectBase {
  80863. private __brand: void;
  80864. label: string | undefined;
  80865. }
  80866. declare class GPUBuffer implements GPUObjectBase {
  80867. private __brand: void;
  80868. label: string | undefined;
  80869. destroy(): void;
  80870. unmap(): void;
  80871. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  80872. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  80873. }
  80874. declare class GPUCommandBuffer implements GPUObjectBase {
  80875. private __brand: void;
  80876. label: string | undefined;
  80877. readonly executionTime: Promise<number>;
  80878. }
  80879. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  80880. declare class GPUCommandEncoder implements GPUObjectBase {
  80881. private __brand: void;
  80882. label: string | undefined;
  80883. beginComputePass(
  80884. descriptor?: GPUComputePassDescriptor
  80885. ): GPUComputePassEncoder;
  80886. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  80887. copyBufferToBuffer(
  80888. source: GPUBuffer,
  80889. sourceOffset: number,
  80890. destination: GPUBuffer,
  80891. destinationOffset: number,
  80892. size: number
  80893. ): void;
  80894. copyBufferToTexture(
  80895. source: GPUBufferCopyView,
  80896. destination: GPUTextureCopyView,
  80897. copySize: GPUExtent3D
  80898. ): void;
  80899. copyTextureToBuffer(
  80900. source: GPUTextureCopyView,
  80901. destination: GPUBufferCopyView,
  80902. copySize: GPUExtent3D
  80903. ): void;
  80904. copyTextureToTexture(
  80905. source: GPUTextureCopyView,
  80906. destination: GPUTextureCopyView,
  80907. copySize: GPUExtent3D
  80908. ): void;
  80909. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  80910. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  80911. popDebugGroup(): void;
  80912. pushDebugGroup(groupLabel: string): void;
  80913. insertDebugMarker(markerLabel: string): void;
  80914. }
  80915. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  80916. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  80917. private __brand: void;
  80918. label: string | undefined;
  80919. setBindGroup(
  80920. index: number,
  80921. bindGroup: GPUBindGroup,
  80922. dynamicOffsets?: Iterable<number>
  80923. ): void;
  80924. popDebugGroup(): void;
  80925. pushDebugGroup(groupLabel: string): void;
  80926. insertDebugMarker(markerLabel: string): void;
  80927. setPipeline(pipeline: GPUComputePipeline): void;
  80928. dispatch(x: number, y?: number, z?: number): void;
  80929. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  80930. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  80931. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  80932. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  80933. endPass(): void;
  80934. }
  80935. declare class GPUComputePipeline implements GPUPipelineBase {
  80936. private __brand: void;
  80937. label: string | undefined;
  80938. getBindGroupLayout(index: number): GPUBindGroupLayout;
  80939. }
  80940. interface GPUObjectBase {
  80941. label: string | undefined;
  80942. }
  80943. interface GPUObjectDescriptorBase {
  80944. label?: string;
  80945. }
  80946. // SwapChain / CanvasContext
  80947. declare class GPUCanvasContext {
  80948. private __brand: void;
  80949. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  80950. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  80951. }
  80952. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  80953. private __brand: void;
  80954. label: string | undefined;
  80955. readonly adapter: GPUAdapter;
  80956. readonly extensions: GPUExtensionName[];
  80957. readonly limits: Required<GPULimits>;
  80958. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  80959. createBindGroupLayout(
  80960. descriptor: GPUBindGroupLayoutDescriptor
  80961. ): GPUBindGroupLayout;
  80962. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  80963. createPipelineLayout(
  80964. descriptor: GPUPipelineLayoutDescriptor
  80965. ): GPUPipelineLayout;
  80966. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  80967. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  80968. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  80969. createComputePipeline(
  80970. descriptor: GPUComputePipelineDescriptor
  80971. ): GPUComputePipeline;
  80972. createRenderPipeline(
  80973. descriptor: GPURenderPipelineDescriptor
  80974. ): GPURenderPipeline;
  80975. createReadyComputePipeline(
  80976. descriptor: GPUComputePipelineDescriptor
  80977. ): Promise<GPUComputePipeline>;
  80978. createReadyRenderPipeline(
  80979. descriptor: GPURenderPipelineDescriptor
  80980. ): Promise<GPURenderPipeline>;
  80981. createCommandEncoder(
  80982. descriptor?: GPUCommandEncoderDescriptor
  80983. ): GPUCommandEncoder;
  80984. createRenderBundleEncoder(
  80985. descriptor: GPURenderBundleEncoderDescriptor
  80986. ): GPURenderBundleEncoder;
  80987. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  80988. defaultQueue: GPUQueue;
  80989. pushErrorScope(filter: GPUErrorFilter): void;
  80990. popErrorScope(): Promise<GPUError | null>;
  80991. onuncapturederror: Event | undefined;
  80992. readonly lost: Promise<GPUDeviceLostInfo>;
  80993. }
  80994. declare class GPUFence implements GPUObjectBase {
  80995. private __brand: void;
  80996. label: string | undefined;
  80997. getCompletedValue(): number;
  80998. onCompletion(completionValue: number): Promise<void>;
  80999. }
  81000. interface GPUPipelineBase extends GPUObjectBase {
  81001. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81002. }
  81003. declare class GPUPipelineLayout implements GPUObjectBase {
  81004. private __brand: void;
  81005. label: string | undefined;
  81006. }
  81007. interface GPUProgrammablePassEncoder {
  81008. setBindGroup(
  81009. index: number,
  81010. bindGroup: GPUBindGroup,
  81011. dynamicOffsets?: Iterable<number>
  81012. ): void;
  81013. popDebugGroup(): void;
  81014. pushDebugGroup(groupLabel: string): void;
  81015. insertDebugMarker(markerLabel: string): void;
  81016. }
  81017. declare class GPUQueue implements GPUObjectBase {
  81018. private __brand: void;
  81019. label: string | undefined;
  81020. signal(fence: GPUFence, signalValue: number): void;
  81021. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  81022. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  81023. writeBuffer(buffer: GPUBuffer,
  81024. bufferOffset: number,
  81025. data: BufferSource | ArrayBuffer,
  81026. dataOffset?: number,
  81027. size?: number): void;
  81028. writeTexture(destination: GPUTextureCopyView,
  81029. data: BufferSource | ArrayBuffer,
  81030. dataLayout: GPUTextureDataLayout,
  81031. size: GPUExtent3D): void;
  81032. copyImageBitmapToTexture(
  81033. source: GPUImageBitmapCopyView,
  81034. destination: GPUTextureCopyView,
  81035. copySize: GPUExtent3D
  81036. ): void;
  81037. }
  81038. type GPUQueryType =
  81039. | "occlusion"
  81040. | "timestamp"
  81041. | "pipeline-statistics";
  81042. type GPUPipelineStatisticName =
  81043. | "vertex-shader-invocations"
  81044. | "clipper-invocations"
  81045. | "clipper-primitives-out"
  81046. | "fragment-shader-invocations"
  81047. | "compute-shader-invocations";
  81048. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  81049. type: GPUQueryType;
  81050. count: number;
  81051. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  81052. }
  81053. declare class GPUQuerySet implements GPUObjectBase {
  81054. private __brand: void;
  81055. label: string | undefined;
  81056. destroy(): void;
  81057. }
  81058. interface GPURenderEncoderBase {
  81059. setPipeline(pipeline: GPURenderPipeline): void;
  81060. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  81061. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81062. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  81063. draw(
  81064. vertexCount: number,
  81065. instanceCount?: number,
  81066. firstVertex?: number,
  81067. firstInstance?: number
  81068. ): void;
  81069. drawIndexed(
  81070. indexCount: number,
  81071. instanceCount?: number,
  81072. firstIndex?: number,
  81073. baseVertex?: number,
  81074. firstInstance?: number
  81075. ): void;
  81076. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81077. drawIndexedIndirect(
  81078. indirectBuffer: GPUBuffer,
  81079. indirectOffset: number
  81080. ): void;
  81081. }
  81082. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  81083. private __brand: void;
  81084. label: string | undefined;
  81085. setBindGroup(
  81086. index: number,
  81087. bindGroup: GPUBindGroup,
  81088. dynamicOffsets?: Iterable<number>
  81089. ): void;
  81090. popDebugGroup(): void;
  81091. pushDebugGroup(groupLabel: string): void;
  81092. insertDebugMarker(markerLabel: string): void;
  81093. setPipeline(pipeline: GPURenderPipeline): void;
  81094. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81095. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81096. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81097. draw(
  81098. vertexCount: number,
  81099. instanceCount?: number,
  81100. firstVertex?: number,
  81101. firstInstance?: number
  81102. ): void;
  81103. drawIndexed(
  81104. indexCount: number,
  81105. instanceCount?: number,
  81106. firstIndex?: number,
  81107. baseVertex?: number,
  81108. firstInstance?: number
  81109. ): void;
  81110. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81111. drawIndexedIndirect(
  81112. indirectBuffer: GPUBuffer,
  81113. indirectOffset: number
  81114. ): void;
  81115. setViewport(
  81116. x: number,
  81117. y: number,
  81118. width: number,
  81119. height: number,
  81120. minDepth: number,
  81121. maxDepth: number
  81122. ): void;
  81123. setScissorRect(x: number, y: number, width: number, height: number): void;
  81124. setBlendColor(color: GPUColor): void;
  81125. setStencilReference(reference: number): void;
  81126. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81127. beginOcclusionQuery(queryIndex: number): void;
  81128. endOcclusionQuery(): void;
  81129. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81130. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81131. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  81132. endPass(): void;
  81133. }
  81134. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  81135. declare class GPURenderBundle implements GPUObjectBase {
  81136. private __brand: void;
  81137. label: string | undefined;
  81138. }
  81139. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  81140. private __brand: void;
  81141. label: string | undefined;
  81142. setBindGroup(
  81143. index: number,
  81144. bindGroup: GPUBindGroup,
  81145. dynamicOffsets?: Iterable<number>
  81146. ): void;
  81147. popDebugGroup(): void;
  81148. pushDebugGroup(groupLabel: string): void;
  81149. insertDebugMarker(markerLabel: string): void;
  81150. setPipeline(pipeline: GPURenderPipeline): void;
  81151. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81152. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81153. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81154. draw(
  81155. vertexCount: number,
  81156. instanceCount?: number,
  81157. firstVertex?: number,
  81158. firstInstance?: number
  81159. ): void;
  81160. drawIndexed(
  81161. indexCount: number,
  81162. instanceCount?: number,
  81163. firstIndex?: number,
  81164. baseVertex?: number,
  81165. firstInstance?: number
  81166. ): void;
  81167. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81168. drawIndexedIndirect(
  81169. indirectBuffer: GPUBuffer,
  81170. indirectOffset: number
  81171. ): void;
  81172. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  81173. }
  81174. interface GPURenderBundleEncoderDescriptor
  81175. extends GPUObjectDescriptorBase {
  81176. colorFormats: Iterable<GPUTextureFormat>;
  81177. depthStencilFormat?: GPUTextureFormat;
  81178. sampleCount?: number;
  81179. }
  81180. declare class GPURenderPipeline implements GPUPipelineBase {
  81181. private __brand: void;
  81182. label: string | undefined;
  81183. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81184. }
  81185. declare class GPUSampler implements GPUObjectBase {
  81186. private __brand: void;
  81187. label: string | undefined;
  81188. }
  81189. type GPUCompilationMessageType =
  81190. | "error"
  81191. | "warning"
  81192. | "info";
  81193. interface GPUCompilationMessage {
  81194. readonly message: string;
  81195. readonly type: GPUCompilationMessageType;
  81196. readonly lineNum: number;
  81197. readonly linePos: number;
  81198. }
  81199. interface GPUCompilationInfo {
  81200. readonly messages: readonly GPUCompilationMessage[];
  81201. }
  81202. declare class GPUShaderModule implements GPUObjectBase {
  81203. private __brand: void;
  81204. label: string | undefined;
  81205. compilationInfo(): Promise<GPUCompilationInfo>;
  81206. }
  81207. declare class GPUSwapChain implements GPUObjectBase {
  81208. private __brand: void;
  81209. label: string | undefined;
  81210. getCurrentTexture(): GPUTexture;
  81211. }
  81212. declare class GPUTexture implements GPUObjectBase {
  81213. private __brand: void;
  81214. label: string | undefined;
  81215. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81216. destroy(): void;
  81217. }
  81218. declare class GPUTextureView implements GPUObjectBase {
  81219. private __brand: void;
  81220. label: string | undefined;
  81221. }
  81222. type GPUPowerPreference = "low-power" | "high-performance";
  81223. interface GPURequestAdapterOptions {
  81224. powerPreference?: GPUPowerPreference;
  81225. }
  81226. declare class GPU {
  81227. private __brand: void;
  81228. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81229. }
  81230. // ****************************************************************************
  81231. // ERROR SCOPES
  81232. // ****************************************************************************
  81233. type GPUErrorFilter = "out-of-memory" | "validation";
  81234. declare class GPUOutOfMemoryError {
  81235. private __brand: void;
  81236. constructor();
  81237. }
  81238. declare class GPUValidationError {
  81239. private __brand: void;
  81240. constructor(message: string);
  81241. readonly message: string;
  81242. }
  81243. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81244. // ****************************************************************************
  81245. // TELEMETRY
  81246. // ****************************************************************************
  81247. declare class GPUUncapturedErrorEvent extends Event {
  81248. private __brand: void;
  81249. constructor(
  81250. type: string,
  81251. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81252. );
  81253. readonly error: GPUError;
  81254. }
  81255. interface GPUUncapturedErrorEventInit extends EventInit {
  81256. error: GPUError;
  81257. }
  81258. declare class GPUDeviceLostInfo {
  81259. private __brand: void;
  81260. readonly message: string;
  81261. }
  81262. // Type definitions for WebVR API
  81263. // Project: https://w3c.github.io/webvr/
  81264. // Definitions by: six a <https://github.com/lostfictions>
  81265. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81266. interface VRDisplay extends EventTarget {
  81267. /**
  81268. * Dictionary of capabilities describing the VRDisplay.
  81269. */
  81270. readonly capabilities: VRDisplayCapabilities;
  81271. /**
  81272. * z-depth defining the far plane of the eye view frustum
  81273. * enables mapping of values in the render target depth
  81274. * attachment to scene coordinates. Initially set to 10000.0.
  81275. */
  81276. depthFar: number;
  81277. /**
  81278. * z-depth defining the near plane of the eye view frustum
  81279. * enables mapping of values in the render target depth
  81280. * attachment to scene coordinates. Initially set to 0.01.
  81281. */
  81282. depthNear: number;
  81283. /**
  81284. * An identifier for this distinct VRDisplay. Used as an
  81285. * association point in the Gamepad API.
  81286. */
  81287. readonly displayId: number;
  81288. /**
  81289. * A display name, a user-readable name identifying it.
  81290. */
  81291. readonly displayName: string;
  81292. readonly isConnected: boolean;
  81293. readonly isPresenting: boolean;
  81294. /**
  81295. * If this VRDisplay supports room-scale experiences, the optional
  81296. * stage attribute contains details on the room-scale parameters.
  81297. */
  81298. readonly stageParameters: VRStageParameters | null;
  81299. /**
  81300. * Passing the value returned by `requestAnimationFrame` to
  81301. * `cancelAnimationFrame` will unregister the callback.
  81302. * @param handle Define the hanle of the request to cancel
  81303. */
  81304. cancelAnimationFrame(handle: number): void;
  81305. /**
  81306. * Stops presenting to the VRDisplay.
  81307. * @returns a promise to know when it stopped
  81308. */
  81309. exitPresent(): Promise<void>;
  81310. /**
  81311. * Return the current VREyeParameters for the given eye.
  81312. * @param whichEye Define the eye we want the parameter for
  81313. * @returns the eye parameters
  81314. */
  81315. getEyeParameters(whichEye: string): VREyeParameters;
  81316. /**
  81317. * Populates the passed VRFrameData with the information required to render
  81318. * the current frame.
  81319. * @param frameData Define the data structure to populate
  81320. * @returns true if ok otherwise false
  81321. */
  81322. getFrameData(frameData: VRFrameData): boolean;
  81323. /**
  81324. * Get the layers currently being presented.
  81325. * @returns the list of VR layers
  81326. */
  81327. getLayers(): VRLayer[];
  81328. /**
  81329. * Return a VRPose containing the future predicted pose of the VRDisplay
  81330. * when the current frame will be presented. The value returned will not
  81331. * change until JavaScript has returned control to the browser.
  81332. *
  81333. * The VRPose will contain the position, orientation, velocity,
  81334. * and acceleration of each of these properties.
  81335. * @returns the pose object
  81336. */
  81337. getPose(): VRPose;
  81338. /**
  81339. * Return the current instantaneous pose of the VRDisplay, with no
  81340. * prediction applied.
  81341. * @returns the current instantaneous pose
  81342. */
  81343. getImmediatePose(): VRPose;
  81344. /**
  81345. * The callback passed to `requestAnimationFrame` will be called
  81346. * any time a new frame should be rendered. When the VRDisplay is
  81347. * presenting the callback will be called at the native refresh
  81348. * rate of the HMD. When not presenting this function acts
  81349. * identically to how window.requestAnimationFrame acts. Content should
  81350. * make no assumptions of frame rate or vsync behavior as the HMD runs
  81351. * asynchronously from other displays and at differing refresh rates.
  81352. * @param callback Define the eaction to run next frame
  81353. * @returns the request handle it
  81354. */
  81355. requestAnimationFrame(callback: FrameRequestCallback): number;
  81356. /**
  81357. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  81358. * Repeat calls while already presenting will update the VRLayers being displayed.
  81359. * @param layers Define the list of layer to present
  81360. * @returns a promise to know when the request has been fulfilled
  81361. */
  81362. requestPresent(layers: VRLayer[]): Promise<void>;
  81363. /**
  81364. * Reset the pose for this display, treating its current position and
  81365. * orientation as the "origin/zero" values. VRPose.position,
  81366. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  81367. * updated when calling resetPose(). This should be called in only
  81368. * sitting-space experiences.
  81369. */
  81370. resetPose(): void;
  81371. /**
  81372. * The VRLayer provided to the VRDisplay will be captured and presented
  81373. * in the HMD. Calling this function has the same effect on the source
  81374. * canvas as any other operation that uses its source image, and canvases
  81375. * created without preserveDrawingBuffer set to true will be cleared.
  81376. * @param pose Define the pose to submit
  81377. */
  81378. submitFrame(pose?: VRPose): void;
  81379. }
  81380. declare var VRDisplay: {
  81381. prototype: VRDisplay;
  81382. new(): VRDisplay;
  81383. };
  81384. interface VRLayer {
  81385. leftBounds?: number[] | Float32Array | null;
  81386. rightBounds?: number[] | Float32Array | null;
  81387. source?: HTMLCanvasElement | null;
  81388. }
  81389. interface VRDisplayCapabilities {
  81390. readonly canPresent: boolean;
  81391. readonly hasExternalDisplay: boolean;
  81392. readonly hasOrientation: boolean;
  81393. readonly hasPosition: boolean;
  81394. readonly maxLayers: number;
  81395. }
  81396. interface VREyeParameters {
  81397. /** @deprecated */
  81398. readonly fieldOfView: VRFieldOfView;
  81399. readonly offset: Float32Array;
  81400. readonly renderHeight: number;
  81401. readonly renderWidth: number;
  81402. }
  81403. interface VRFieldOfView {
  81404. readonly downDegrees: number;
  81405. readonly leftDegrees: number;
  81406. readonly rightDegrees: number;
  81407. readonly upDegrees: number;
  81408. }
  81409. interface VRFrameData {
  81410. readonly leftProjectionMatrix: Float32Array;
  81411. readonly leftViewMatrix: Float32Array;
  81412. readonly pose: VRPose;
  81413. readonly rightProjectionMatrix: Float32Array;
  81414. readonly rightViewMatrix: Float32Array;
  81415. readonly timestamp: number;
  81416. }
  81417. interface VRPose {
  81418. readonly angularAcceleration: Float32Array | null;
  81419. readonly angularVelocity: Float32Array | null;
  81420. readonly linearAcceleration: Float32Array | null;
  81421. readonly linearVelocity: Float32Array | null;
  81422. readonly orientation: Float32Array | null;
  81423. readonly position: Float32Array | null;
  81424. readonly timestamp: number;
  81425. }
  81426. interface VRStageParameters {
  81427. sittingToStandingTransform?: Float32Array;
  81428. sizeX?: number;
  81429. sizeY?: number;
  81430. }
  81431. interface Navigator {
  81432. getVRDisplays(): Promise<VRDisplay[]>;
  81433. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  81434. }
  81435. interface Window {
  81436. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  81437. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  81438. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  81439. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81440. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81441. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  81442. }
  81443. interface Gamepad {
  81444. readonly displayId: number;
  81445. }
  81446. /**
  81447. * Available session modes
  81448. */
  81449. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  81450. /**
  81451. * Reference space types
  81452. */
  81453. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  81454. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  81455. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  81456. /**
  81457. * Handedness types
  81458. */
  81459. type XRHandedness = "none" | "left" | "right";
  81460. /**
  81461. * InputSource target ray modes
  81462. */
  81463. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  81464. /**
  81465. * Eye types
  81466. */
  81467. type XREye = "none" | "left" | "right";
  81468. /**
  81469. * Type of XR events available
  81470. */
  81471. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  81472. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  81473. type XRPlaneSet = Set<XRPlane>;
  81474. type XRAnchorSet = Set<XRAnchor>;
  81475. type XREventHandler = (callback: any) => void;
  81476. interface XRLayer extends EventTarget {}
  81477. interface XRSessionInit {
  81478. optionalFeatures?: string[];
  81479. requiredFeatures?: string[];
  81480. trackedImages?: XRTrackedImageInit[];
  81481. }
  81482. interface XRSessionEvent extends Event {
  81483. readonly session: XRSession;
  81484. }
  81485. interface XRSystem {
  81486. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  81487. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  81488. }
  81489. interface XRViewport {
  81490. readonly x: number;
  81491. readonly y: number;
  81492. readonly width: number;
  81493. readonly height: number;
  81494. }
  81495. interface XRWebGLLayerInit {
  81496. antialias?: boolean;
  81497. depth?: boolean;
  81498. stencil?: boolean;
  81499. alpha?: boolean;
  81500. multiview?: boolean;
  81501. framebufferScaleFactor?: number;
  81502. }
  81503. declare class XRWebGLLayer {
  81504. static getNativeFramebufferScaleFactor(session: XRSession): number;
  81505. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  81506. readonly antialias: boolean;
  81507. readonly framebuffer: WebGLFramebuffer;
  81508. readonly framebufferWidth: number;
  81509. readonly framebufferHeight: number;
  81510. readonly ignoreDepthValues: boolean;
  81511. getViewport: (view: XRView) => XRViewport;
  81512. }
  81513. // tslint:disable-next-line no-empty-interface
  81514. interface XRSpace extends EventTarget {}
  81515. interface XRRenderState {
  81516. readonly baseLayer?: XRWebGLLayer;
  81517. readonly depthFar: number;
  81518. readonly depthNear: number;
  81519. readonly inlineVerticalFieldOfView?: number;
  81520. }
  81521. interface XRRenderStateInit extends XRRenderState {
  81522. baseLayer: XRWebGLLayer;
  81523. depthFar: number;
  81524. depthNear: number;
  81525. inlineVerticalFieldOfView?: number;
  81526. layers?: XRLayer[];
  81527. }
  81528. interface XRReferenceSpace extends XRSpace {
  81529. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  81530. onreset: XREventHandler;
  81531. }
  81532. interface XRBoundedReferenceSpace extends XRSpace {
  81533. readonly boundsGeometry: DOMPointReadOnly[];
  81534. }
  81535. interface XRInputSource {
  81536. readonly handedness: XRHandedness;
  81537. readonly targetRayMode: XRTargetRayMode;
  81538. readonly targetRaySpace: XRSpace;
  81539. readonly gripSpace?: XRSpace;
  81540. readonly gamepad?: Gamepad;
  81541. readonly profiles: Array<string>;
  81542. readonly hand?: XRHand;
  81543. }
  81544. interface XRPose {
  81545. readonly transform: XRRigidTransform;
  81546. readonly emulatedPosition: boolean;
  81547. }
  81548. interface XRWorldInformation {
  81549. detectedPlanes?: XRPlaneSet;
  81550. }
  81551. interface XRFrame {
  81552. readonly session: XRSession;
  81553. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  81554. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  81555. // AR
  81556. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  81557. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  81558. // Anchors
  81559. trackedAnchors?: XRAnchorSet;
  81560. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  81561. // World geometries
  81562. worldInformation?: XRWorldInformation;
  81563. // Hand tracking
  81564. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  81565. // Image tracking
  81566. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  81567. }
  81568. interface XRInputSourceEvent extends Event {
  81569. readonly frame: XRFrame;
  81570. readonly inputSource: XRInputSource;
  81571. }
  81572. type XRInputSourceArray = XRInputSource[];
  81573. interface XRSession {
  81574. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  81575. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  81576. /**
  81577. * Returns a list of this session's XRInputSources, each representing an input device
  81578. * used to control the camera and/or scene.
  81579. */
  81580. readonly inputSources: Array<XRInputSource>;
  81581. /**
  81582. * object which contains options affecting how the imagery is rendered.
  81583. * This includes things such as the near and far clipping planes
  81584. */
  81585. readonly renderState: XRRenderState;
  81586. readonly visibilityState: XRVisibilityState;
  81587. /**
  81588. * Removes a callback from the animation frame painting callback from
  81589. * XRSession's set of animation frame rendering callbacks, given the
  81590. * identifying handle returned by a previous call to requestAnimationFrame().
  81591. */
  81592. cancelAnimationFrame: (handle: number) => void;
  81593. /**
  81594. * Ends the WebXR session. Returns a promise which resolves when the
  81595. * session has been shut down.
  81596. */
  81597. end(): Promise<void>;
  81598. /**
  81599. * Schedules the specified method to be called the next time the user agent
  81600. * is working on rendering an animation frame for the WebXR device. Returns an
  81601. * integer value which can be used to identify the request for the purposes of
  81602. * canceling the callback using cancelAnimationFrame(). This method is comparable
  81603. * to the Window.requestAnimationFrame() method.
  81604. */
  81605. requestAnimationFrame: XRFrameRequestCallback;
  81606. /**
  81607. * Requests that a new XRReferenceSpace of the specified type be created.
  81608. * Returns a promise which resolves with the XRReferenceSpace or
  81609. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  81610. * the requested space type isn't supported by the device.
  81611. */
  81612. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  81613. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  81614. onend: XREventHandler;
  81615. oninputsourceschange: XREventHandler;
  81616. onselect: XREventHandler;
  81617. onselectstart: XREventHandler;
  81618. onselectend: XREventHandler;
  81619. onsqueeze: XREventHandler;
  81620. onsqueezestart: XREventHandler;
  81621. onsqueezeend: XREventHandler;
  81622. onvisibilitychange: XREventHandler;
  81623. // hit test
  81624. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  81625. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  81626. // legacy AR hit test
  81627. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  81628. // legacy plane detection
  81629. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  81630. // image tracking
  81631. getTrackedImageScores?(): XRImageTrackingScore[];
  81632. }
  81633. interface XRViewerPose extends XRPose {
  81634. readonly views: Array<XRView>;
  81635. }
  81636. declare class XRRigidTransform {
  81637. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  81638. position: DOMPointReadOnly;
  81639. orientation: DOMPointReadOnly;
  81640. matrix: Float32Array;
  81641. inverse: XRRigidTransform;
  81642. }
  81643. interface XRView {
  81644. readonly eye: XREye;
  81645. readonly projectionMatrix: Float32Array;
  81646. readonly transform: XRRigidTransform;
  81647. readonly recommendedViewportScale?: number;
  81648. requestViewportScale(scale: number): void;
  81649. }
  81650. interface XRInputSourceChangeEvent extends Event {
  81651. session: XRSession;
  81652. removed: Array<XRInputSource>;
  81653. added: Array<XRInputSource>;
  81654. }
  81655. // Experimental/Draft features
  81656. declare class XRRay {
  81657. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  81658. origin: DOMPointReadOnly;
  81659. direction: DOMPointReadOnly;
  81660. matrix: Float32Array;
  81661. }
  81662. declare enum XRHitTestTrackableType {
  81663. "point",
  81664. "plane",
  81665. "mesh",
  81666. }
  81667. interface XRHitResult {
  81668. hitMatrix: Float32Array;
  81669. }
  81670. interface XRTransientInputHitTestResult {
  81671. readonly inputSource: XRInputSource;
  81672. readonly results: Array<XRHitTestResult>;
  81673. }
  81674. interface XRHitTestResult {
  81675. getPose(baseSpace: XRSpace): XRPose | undefined;
  81676. // When anchor system is enabled
  81677. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  81678. }
  81679. interface XRHitTestSource {
  81680. cancel(): void;
  81681. }
  81682. interface XRTransientInputHitTestSource {
  81683. cancel(): void;
  81684. }
  81685. interface XRHitTestOptionsInit {
  81686. space: XRSpace;
  81687. entityTypes?: Array<XRHitTestTrackableType>;
  81688. offsetRay?: XRRay;
  81689. }
  81690. interface XRTransientInputHitTestOptionsInit {
  81691. profile: string;
  81692. entityTypes?: Array<XRHitTestTrackableType>;
  81693. offsetRay?: XRRay;
  81694. }
  81695. interface XRAnchor {
  81696. anchorSpace: XRSpace;
  81697. delete(): void;
  81698. }
  81699. interface XRPlane {
  81700. orientation: "Horizontal" | "Vertical";
  81701. planeSpace: XRSpace;
  81702. polygon: Array<DOMPointReadOnly>;
  81703. lastChangedTime: number;
  81704. }
  81705. interface XRJointSpace extends XRSpace {}
  81706. interface XRJointPose extends XRPose {
  81707. radius: number | undefined;
  81708. }
  81709. interface XRHand extends Iterable<XRJointSpace> {
  81710. readonly length: number;
  81711. [index: number]: XRJointSpace;
  81712. readonly WRIST: number;
  81713. readonly THUMB_METACARPAL: number;
  81714. readonly THUMB_PHALANX_PROXIMAL: number;
  81715. readonly THUMB_PHALANX_DISTAL: number;
  81716. readonly THUMB_PHALANX_TIP: number;
  81717. readonly INDEX_METACARPAL: number;
  81718. readonly INDEX_PHALANX_PROXIMAL: number;
  81719. readonly INDEX_PHALANX_INTERMEDIATE: number;
  81720. readonly INDEX_PHALANX_DISTAL: number;
  81721. readonly INDEX_PHALANX_TIP: number;
  81722. readonly MIDDLE_METACARPAL: number;
  81723. readonly MIDDLE_PHALANX_PROXIMAL: number;
  81724. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  81725. readonly MIDDLE_PHALANX_DISTAL: number;
  81726. readonly MIDDLE_PHALANX_TIP: number;
  81727. readonly RING_METACARPAL: number;
  81728. readonly RING_PHALANX_PROXIMAL: number;
  81729. readonly RING_PHALANX_INTERMEDIATE: number;
  81730. readonly RING_PHALANX_DISTAL: number;
  81731. readonly RING_PHALANX_TIP: number;
  81732. readonly LITTLE_METACARPAL: number;
  81733. readonly LITTLE_PHALANX_PROXIMAL: number;
  81734. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  81735. readonly LITTLE_PHALANX_DISTAL: number;
  81736. readonly LITTLE_PHALANX_TIP: number;
  81737. }
  81738. type XRImageTrackingState = "tracked" | "emulated";
  81739. type XRImageTrackingScore = "untrackable" | "trackable";
  81740. interface XRTrackedImageInit {
  81741. image: ImageBitmap;
  81742. widthInMeters: number;
  81743. }
  81744. interface XRImageTrackingResult {
  81745. readonly imageSpace: XRSpace;
  81746. readonly index: number;
  81747. readonly trackingState: XRImageTrackingState;
  81748. readonly measuredWidthInMeters: number;
  81749. }
  81750. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  81751. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  81752. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  81753. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  81754. interface XRSceneObject {
  81755. type: XRSceneObjectType;
  81756. }
  81757. interface XRFieldOfView {
  81758. angleLeft: number;
  81759. angleRight: number;
  81760. angleUp: number;
  81761. angleDown: number;
  81762. }
  81763. interface XRFrustum {
  81764. position: DOMPointReadOnly;
  81765. orientation: DOMPointReadOnly;
  81766. fieldOfView: XRFieldOfView;
  81767. farDistance: number;
  81768. }
  81769. interface XRPlane {
  81770. parentSceneObject?: XRSceneObject;
  81771. }
  81772. interface XRMesh {
  81773. meshSpace: XRSpace;
  81774. positions: Float32Array;
  81775. indices: Uint32Array;
  81776. normals?: Float32Array;
  81777. lastChangedTime: number;
  81778. parentSceneObject?: XRSceneObject;
  81779. }
  81780. interface XRFrustumDetectionBoundary {
  81781. type: "frustum";
  81782. frustum: XRFrustum;
  81783. }
  81784. interface XRSphereDetectionBoundary {
  81785. type: "sphere";
  81786. radius: number;
  81787. }
  81788. interface XRBoxDetectionBoundary {
  81789. type: "box";
  81790. extent: DOMPointReadOnly;
  81791. }
  81792. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  81793. interface XRGeometryDetectorOptions {
  81794. detectionBoundary?: XRDetectionBoundary;
  81795. updateInterval?: number;
  81796. }
  81797. interface XRSession {
  81798. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  81799. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  81800. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  81801. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  81802. }
  81803. interface XRFrame {
  81804. featurePointCloud?: Array<number>;
  81805. }
  81806. type XRMeshSet = Set<XRMesh>;
  81807. interface XRWorldInformation {
  81808. detectedMeshes?: XRMeshSet;
  81809. }
  81810. /**
  81811. * @ignore
  81812. */
  81813. declare module BABYLON.GLTF2.Exporter {
  81814. }
  81815. /**
  81816. * @ignore
  81817. */
  81818. declare module BABYLON.GLTF1 {
  81819. }
  81820. declare module BABYLON.GUI {
  81821. /**
  81822. * Interface used to define a control that can receive focus
  81823. */
  81824. export interface IFocusableControl {
  81825. /**
  81826. * Function called when the control receives the focus
  81827. */
  81828. onFocus(): void;
  81829. /**
  81830. * Function called when the control loses the focus
  81831. */
  81832. onBlur(): void;
  81833. /**
  81834. * Function called to let the control handle keyboard events
  81835. * @param evt defines the current keyboard event
  81836. */
  81837. processKeyboard(evt: KeyboardEvent): void;
  81838. /**
  81839. * Function called to get the list of controls that should not steal the focus from this control
  81840. * @returns an array of controls
  81841. */
  81842. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  81843. /**
  81844. * Function to focus the control programmatically
  81845. */
  81846. focus(): void;
  81847. /**
  81848. * Function to unfocus the control programmatically
  81849. */
  81850. blur(): void;
  81851. }
  81852. }
  81853. declare module BABYLON.GUI {
  81854. /**
  81855. * Class used to specific a value and its associated unit
  81856. */
  81857. export class ValueAndUnit {
  81858. /** defines the unit to store */
  81859. unit: number;
  81860. /** defines a boolean indicating if the value can be negative */
  81861. negativeValueAllowed: boolean;
  81862. private _value;
  81863. private _originalUnit;
  81864. /**
  81865. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  81866. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  81867. */
  81868. ignoreAdaptiveScaling: boolean;
  81869. /**
  81870. * Creates a new ValueAndUnit
  81871. * @param value defines the value to store
  81872. * @param unit defines the unit to store
  81873. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  81874. */
  81875. constructor(value: number,
  81876. /** defines the unit to store */
  81877. unit?: number,
  81878. /** defines a boolean indicating if the value can be negative */
  81879. negativeValueAllowed?: boolean);
  81880. /** Gets a boolean indicating if the value is a percentage */
  81881. get isPercentage(): boolean;
  81882. /** Gets a boolean indicating if the value is store as pixel */
  81883. get isPixel(): boolean;
  81884. /** Gets direct internal value */
  81885. get internalValue(): number;
  81886. /**
  81887. * Gets value as pixel
  81888. * @param host defines the root host
  81889. * @param refValue defines the reference value for percentages
  81890. * @returns the value as pixel
  81891. */
  81892. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  81893. /**
  81894. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  81895. * @param value defines the value to store
  81896. * @param unit defines the unit to store
  81897. * @returns the current ValueAndUnit
  81898. */
  81899. updateInPlace(value: number, unit?: number): ValueAndUnit;
  81900. /**
  81901. * Gets the value accordingly to its unit
  81902. * @param host defines the root host
  81903. * @returns the value
  81904. */
  81905. getValue(host: AdvancedDynamicTexture): number;
  81906. /**
  81907. * Gets a string representation of the value
  81908. * @param host defines the root host
  81909. * @param decimals defines an optional number of decimals to display
  81910. * @returns a string
  81911. */
  81912. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  81913. /**
  81914. * Store a value parsed from a string
  81915. * @param source defines the source string
  81916. * @returns true if the value was successfully parsed
  81917. */
  81918. fromString(source: string | number): boolean;
  81919. private static _Regex;
  81920. private static _UNITMODE_PERCENTAGE;
  81921. private static _UNITMODE_PIXEL;
  81922. /** UNITMODE_PERCENTAGE */
  81923. static get UNITMODE_PERCENTAGE(): number;
  81924. /** UNITMODE_PIXEL */
  81925. static get UNITMODE_PIXEL(): number;
  81926. }
  81927. }
  81928. declare module BABYLON.GUI {
  81929. /**
  81930. * Define a style used by control to automatically setup properties based on a template.
  81931. * Only support font related properties so far
  81932. */
  81933. export class Style implements BABYLON.IDisposable {
  81934. private _fontFamily;
  81935. private _fontStyle;
  81936. private _fontWeight;
  81937. /** @hidden */
  81938. _host: AdvancedDynamicTexture;
  81939. /** @hidden */
  81940. _fontSize: ValueAndUnit;
  81941. /**
  81942. * BABYLON.Observable raised when the style values are changed
  81943. */
  81944. onChangedObservable: BABYLON.Observable<Style>;
  81945. /**
  81946. * Creates a new style object
  81947. * @param host defines the AdvancedDynamicTexture which hosts this style
  81948. */
  81949. constructor(host: AdvancedDynamicTexture);
  81950. /**
  81951. * Gets or sets the font size
  81952. */
  81953. get fontSize(): string | number;
  81954. set fontSize(value: string | number);
  81955. /**
  81956. * Gets or sets the font family
  81957. */
  81958. get fontFamily(): string;
  81959. set fontFamily(value: string);
  81960. /**
  81961. * Gets or sets the font style
  81962. */
  81963. get fontStyle(): string;
  81964. set fontStyle(value: string);
  81965. /** Gets or sets font weight */
  81966. get fontWeight(): string;
  81967. set fontWeight(value: string);
  81968. /** Dispose all associated resources */
  81969. dispose(): void;
  81970. }
  81971. }
  81972. declare module BABYLON.GUI {
  81973. /**
  81974. * Class used to transport BABYLON.Vector2 information for pointer events
  81975. */
  81976. export class Vector2WithInfo extends BABYLON.Vector2 {
  81977. /** defines the current mouse button index */
  81978. buttonIndex: number;
  81979. /**
  81980. * Creates a new Vector2WithInfo
  81981. * @param source defines the vector2 data to transport
  81982. * @param buttonIndex defines the current mouse button index
  81983. */
  81984. constructor(source: BABYLON.Vector2,
  81985. /** defines the current mouse button index */
  81986. buttonIndex?: number);
  81987. }
  81988. /** Class used to provide 2D matrix features */
  81989. export class Matrix2D {
  81990. /** Gets the internal array of 6 floats used to store matrix data */
  81991. m: Float32Array;
  81992. /**
  81993. * Creates a new matrix
  81994. * @param m00 defines value for (0, 0)
  81995. * @param m01 defines value for (0, 1)
  81996. * @param m10 defines value for (1, 0)
  81997. * @param m11 defines value for (1, 1)
  81998. * @param m20 defines value for (2, 0)
  81999. * @param m21 defines value for (2, 1)
  82000. */
  82001. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  82002. /**
  82003. * Fills the matrix from direct values
  82004. * @param m00 defines value for (0, 0)
  82005. * @param m01 defines value for (0, 1)
  82006. * @param m10 defines value for (1, 0)
  82007. * @param m11 defines value for (1, 1)
  82008. * @param m20 defines value for (2, 0)
  82009. * @param m21 defines value for (2, 1)
  82010. * @returns the current modified matrix
  82011. */
  82012. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  82013. /**
  82014. * Gets matrix determinant
  82015. * @returns the determinant
  82016. */
  82017. determinant(): number;
  82018. /**
  82019. * Inverses the matrix and stores it in a target matrix
  82020. * @param result defines the target matrix
  82021. * @returns the current matrix
  82022. */
  82023. invertToRef(result: Matrix2D): Matrix2D;
  82024. /**
  82025. * Multiplies the current matrix with another one
  82026. * @param other defines the second operand
  82027. * @param result defines the target matrix
  82028. * @returns the current matrix
  82029. */
  82030. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  82031. /**
  82032. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  82033. * @param x defines the x coordinate to transform
  82034. * @param y defines the x coordinate to transform
  82035. * @param result defines the target vector2
  82036. * @returns the current matrix
  82037. */
  82038. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  82039. /**
  82040. * Creates an identity matrix
  82041. * @returns a new matrix
  82042. */
  82043. static Identity(): Matrix2D;
  82044. /**
  82045. * Creates a translation matrix and stores it in a target matrix
  82046. * @param x defines the x coordinate of the translation
  82047. * @param y defines the y coordinate of the translation
  82048. * @param result defines the target matrix
  82049. */
  82050. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  82051. /**
  82052. * Creates a scaling matrix and stores it in a target matrix
  82053. * @param x defines the x coordinate of the scaling
  82054. * @param y defines the y coordinate of the scaling
  82055. * @param result defines the target matrix
  82056. */
  82057. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  82058. /**
  82059. * Creates a rotation matrix and stores it in a target matrix
  82060. * @param angle defines the rotation angle
  82061. * @param result defines the target matrix
  82062. */
  82063. static RotationToRef(angle: number, result: Matrix2D): void;
  82064. private static _TempPreTranslationMatrix;
  82065. private static _TempPostTranslationMatrix;
  82066. private static _TempRotationMatrix;
  82067. private static _TempScalingMatrix;
  82068. private static _TempCompose0;
  82069. private static _TempCompose1;
  82070. private static _TempCompose2;
  82071. /**
  82072. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  82073. * @param tx defines the x coordinate of the translation
  82074. * @param ty defines the y coordinate of the translation
  82075. * @param angle defines the rotation angle
  82076. * @param scaleX defines the x coordinate of the scaling
  82077. * @param scaleY defines the y coordinate of the scaling
  82078. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  82079. * @param result defines the target matrix
  82080. */
  82081. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  82082. }
  82083. }
  82084. declare module BABYLON.GUI {
  82085. /**
  82086. * Class used to store 2D control sizes
  82087. */
  82088. export class Measure {
  82089. /** defines left coordinate */
  82090. left: number;
  82091. /** defines top coordinate */
  82092. top: number;
  82093. /** defines width dimension */
  82094. width: number;
  82095. /** defines height dimension */
  82096. height: number;
  82097. /**
  82098. * Creates a new measure
  82099. * @param left defines left coordinate
  82100. * @param top defines top coordinate
  82101. * @param width defines width dimension
  82102. * @param height defines height dimension
  82103. */
  82104. constructor(
  82105. /** defines left coordinate */
  82106. left: number,
  82107. /** defines top coordinate */
  82108. top: number,
  82109. /** defines width dimension */
  82110. width: number,
  82111. /** defines height dimension */
  82112. height: number);
  82113. /**
  82114. * Copy from another measure
  82115. * @param other defines the other measure to copy from
  82116. */
  82117. copyFrom(other: Measure): void;
  82118. /**
  82119. * Copy from a group of 4 floats
  82120. * @param left defines left coordinate
  82121. * @param top defines top coordinate
  82122. * @param width defines width dimension
  82123. * @param height defines height dimension
  82124. */
  82125. copyFromFloats(left: number, top: number, width: number, height: number): void;
  82126. /**
  82127. * Computes the axis aligned bounding box measure for two given measures
  82128. * @param a Input measure
  82129. * @param b Input measure
  82130. * @param result the resulting bounding measure
  82131. */
  82132. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  82133. /**
  82134. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82135. * @param transform the matrix to transform the measure before computing the AABB
  82136. * @param addX number to add to left
  82137. * @param addY number to add to top
  82138. * @param addWidth number to add to width
  82139. * @param addHeight number to add to height
  82140. * @param result the resulting AABB
  82141. */
  82142. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  82143. /**
  82144. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82145. * @param transform the matrix to transform the measure before computing the AABB
  82146. * @param result the resulting AABB
  82147. */
  82148. transformToRef(transform: Matrix2D, result: Measure): void;
  82149. /**
  82150. * Check equality between this measure and another one
  82151. * @param other defines the other measures
  82152. * @returns true if both measures are equals
  82153. */
  82154. isEqualsTo(other: Measure): boolean;
  82155. /**
  82156. * Creates an empty measure
  82157. * @returns a new measure
  82158. */
  82159. static Empty(): Measure;
  82160. }
  82161. }
  82162. declare module BABYLON.GUI {
  82163. /**
  82164. * Class used to create texture to support 2D GUI elements
  82165. * @see https://doc.babylonjs.com/how_to/gui
  82166. */
  82167. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  82168. private _isDirty;
  82169. private _renderObserver;
  82170. private _resizeObserver;
  82171. private _preKeyboardObserver;
  82172. private _pointerMoveObserver;
  82173. private _pointerObserver;
  82174. private _canvasPointerOutObserver;
  82175. private _canvasBlurObserver;
  82176. private _background;
  82177. /** @hidden */
  82178. _rootContainer: Container;
  82179. /** @hidden */
  82180. _lastPickedControl: Control;
  82181. /** @hidden */
  82182. _lastControlOver: {
  82183. [pointerId: number]: Control;
  82184. };
  82185. /** @hidden */
  82186. _lastControlDown: {
  82187. [pointerId: number]: Control;
  82188. };
  82189. /** @hidden */
  82190. _capturingControl: {
  82191. [pointerId: number]: Control;
  82192. };
  82193. /** @hidden */
  82194. _shouldBlockPointer: boolean;
  82195. /** @hidden */
  82196. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  82197. /** @hidden */
  82198. _linkedControls: Control[];
  82199. private _isFullscreen;
  82200. private _fullscreenViewport;
  82201. private _idealWidth;
  82202. private _idealHeight;
  82203. private _useSmallestIdeal;
  82204. private _renderAtIdealSize;
  82205. private _focusedControl;
  82206. private _blockNextFocusCheck;
  82207. private _renderScale;
  82208. private _rootElement;
  82209. private _cursorChanged;
  82210. private _defaultMousePointerId;
  82211. /** @hidden */
  82212. _numLayoutCalls: number;
  82213. /** Gets the number of layout calls made the last time the ADT has been rendered */
  82214. get numLayoutCalls(): number;
  82215. /** @hidden */
  82216. _numRenderCalls: number;
  82217. /** Gets the number of render calls made the last time the ADT has been rendered */
  82218. get numRenderCalls(): number;
  82219. /**
  82220. * Define type to string to ensure compatibility across browsers
  82221. * Safari doesn't support DataTransfer constructor
  82222. */
  82223. private _clipboardData;
  82224. /**
  82225. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  82226. */
  82227. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  82228. /**
  82229. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  82230. */
  82231. onControlPickedObservable: BABYLON.Observable<Control>;
  82232. /**
  82233. * BABYLON.Observable event triggered before layout is evaluated
  82234. */
  82235. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82236. /**
  82237. * BABYLON.Observable event triggered after the layout was evaluated
  82238. */
  82239. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82240. /**
  82241. * BABYLON.Observable event triggered before the texture is rendered
  82242. */
  82243. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82244. /**
  82245. * BABYLON.Observable event triggered after the texture was rendered
  82246. */
  82247. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82248. /**
  82249. * Gets or sets a boolean defining if alpha is stored as premultiplied
  82250. */
  82251. premulAlpha: boolean;
  82252. /**
  82253. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  82254. */
  82255. applyYInversionOnUpdate: boolean;
  82256. /**
  82257. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  82258. * Useful when you want more antialiasing
  82259. */
  82260. get renderScale(): number;
  82261. set renderScale(value: number);
  82262. /** Gets or sets the background color */
  82263. get background(): string;
  82264. set background(value: string);
  82265. /**
  82266. * Gets or sets the ideal width used to design controls.
  82267. * The GUI will then rescale everything accordingly
  82268. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82269. */
  82270. get idealWidth(): number;
  82271. set idealWidth(value: number);
  82272. /**
  82273. * Gets or sets the ideal height used to design controls.
  82274. * The GUI will then rescale everything accordingly
  82275. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82276. */
  82277. get idealHeight(): number;
  82278. set idealHeight(value: number);
  82279. /**
  82280. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  82281. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82282. */
  82283. get useSmallestIdeal(): boolean;
  82284. set useSmallestIdeal(value: boolean);
  82285. /**
  82286. * Gets or sets a boolean indicating if adaptive scaling must be used
  82287. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82288. */
  82289. get renderAtIdealSize(): boolean;
  82290. set renderAtIdealSize(value: boolean);
  82291. /**
  82292. * Gets the ratio used when in "ideal mode"
  82293. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82294. * */
  82295. get idealRatio(): number;
  82296. /**
  82297. * Gets the underlying layer used to render the texture when in fullscreen mode
  82298. */
  82299. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  82300. /**
  82301. * Gets the root container control
  82302. */
  82303. get rootContainer(): Container;
  82304. /**
  82305. * Returns an array containing the root container.
  82306. * This is mostly used to let the Inspector introspects the ADT
  82307. * @returns an array containing the rootContainer
  82308. */
  82309. getChildren(): Array<Container>;
  82310. /**
  82311. * Will return all controls that are inside this texture
  82312. * @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
  82313. * @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
  82314. * @return all child controls
  82315. */
  82316. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  82317. /**
  82318. * Gets or sets the current focused control
  82319. */
  82320. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  82321. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  82322. /**
  82323. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  82324. */
  82325. get isForeground(): boolean;
  82326. set isForeground(value: boolean);
  82327. /**
  82328. * Gets or set information about clipboardData
  82329. */
  82330. get clipboardData(): string;
  82331. set clipboardData(value: string);
  82332. /**
  82333. * Creates a new AdvancedDynamicTexture
  82334. * @param name defines the name of the texture
  82335. * @param width defines the width of the texture
  82336. * @param height defines the height of the texture
  82337. * @param scene defines the hosting scene
  82338. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  82339. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82340. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82341. */
  82342. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  82343. /**
  82344. * Get the current class name of the texture useful for serialization or dynamic coding.
  82345. * @returns "AdvancedDynamicTexture"
  82346. */
  82347. getClassName(): string;
  82348. /**
  82349. * Function used to execute a function on all controls
  82350. * @param func defines the function to execute
  82351. * @param container defines the container where controls belong. If null the root container will be used
  82352. */
  82353. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  82354. private _useInvalidateRectOptimization;
  82355. /**
  82356. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  82357. */
  82358. get useInvalidateRectOptimization(): boolean;
  82359. set useInvalidateRectOptimization(value: boolean);
  82360. private _invalidatedRectangle;
  82361. /**
  82362. * Invalidates a rectangle area on the gui texture
  82363. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  82364. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  82365. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  82366. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  82367. */
  82368. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  82369. /**
  82370. * Marks the texture as dirty forcing a complete update
  82371. */
  82372. markAsDirty(): void;
  82373. /**
  82374. * Helper function used to create a new style
  82375. * @returns a new style
  82376. * @see https://doc.babylonjs.com/how_to/gui#styles
  82377. */
  82378. createStyle(): Style;
  82379. /**
  82380. * Adds a new control to the root container
  82381. * @param control defines the control to add
  82382. * @returns the current texture
  82383. */
  82384. addControl(control: Control): AdvancedDynamicTexture;
  82385. /**
  82386. * Removes a control from the root container
  82387. * @param control defines the control to remove
  82388. * @returns the current texture
  82389. */
  82390. removeControl(control: Control): AdvancedDynamicTexture;
  82391. /**
  82392. * Release all resources
  82393. */
  82394. dispose(): void;
  82395. private _onResize;
  82396. /** @hidden */
  82397. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  82398. /**
  82399. * Get screen coordinates for a vector3
  82400. * @param position defines the position to project
  82401. * @param worldMatrix defines the world matrix to use
  82402. * @returns the projected position
  82403. */
  82404. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  82405. /**
  82406. * Get screen coordinates for a vector3
  82407. * @param position defines the position to project
  82408. * @param worldMatrix defines the world matrix to use
  82409. * @returns the projected position with Z
  82410. */
  82411. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  82412. private _checkUpdate;
  82413. private _clearMeasure;
  82414. private _render;
  82415. /** @hidden */
  82416. _changeCursor(cursor: string): void;
  82417. /** @hidden */
  82418. _registerLastControlDown(control: Control, pointerId: number): void;
  82419. private _doPicking;
  82420. /** @hidden */
  82421. _cleanControlAfterRemovalFromList(list: {
  82422. [pointerId: number]: Control;
  82423. }, control: Control): void;
  82424. /** @hidden */
  82425. _cleanControlAfterRemoval(control: Control): void;
  82426. /** Attach to all scene events required to support pointer events */
  82427. attach(): void;
  82428. /** @hidden */
  82429. private onClipboardCopy;
  82430. /** @hidden */
  82431. private onClipboardCut;
  82432. /** @hidden */
  82433. private onClipboardPaste;
  82434. /**
  82435. * Register the clipboard Events onto the canvas
  82436. */
  82437. registerClipboardEvents(): void;
  82438. /**
  82439. * Unregister the clipboard Events from the canvas
  82440. */
  82441. unRegisterClipboardEvents(): void;
  82442. /**
  82443. * Connect the texture to a hosting mesh to enable interactions
  82444. * @param mesh defines the mesh to attach to
  82445. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  82446. */
  82447. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  82448. /**
  82449. * Move the focus to a specific control
  82450. * @param control defines the control which will receive the focus
  82451. */
  82452. moveFocusToControl(control: IFocusableControl): void;
  82453. private _manageFocus;
  82454. private _attachToOnPointerOut;
  82455. private _attachToOnBlur;
  82456. /**
  82457. * Serializes the entire GUI system
  82458. * @returns an object with the JSON serialized data
  82459. */
  82460. serializeContent(): any;
  82461. /**
  82462. * Recreate the content of the ADT from a JSON object
  82463. * @param serializedObject define the JSON serialized object to restore from
  82464. */
  82465. parseContent(serializedObject: any): void;
  82466. /**
  82467. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  82468. * @param mesh defines the mesh which will receive the texture
  82469. * @param width defines the texture width (1024 by default)
  82470. * @param height defines the texture height (1024 by default)
  82471. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82472. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  82473. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82474. * @returns a new AdvancedDynamicTexture
  82475. */
  82476. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82477. /**
  82478. * 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
  82479. * @param mesh defines the mesh which will receive the texture
  82480. * @param width defines the texture width (1024 by default)
  82481. * @param height defines the texture height (1024 by default)
  82482. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82483. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82484. * @returns a new AdvancedDynamicTexture
  82485. */
  82486. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82487. /**
  82488. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  82489. * In this mode the texture will rely on a layer for its rendering.
  82490. * This allows it to be treated like any other layer.
  82491. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  82492. * LayerMask is set through advancedTexture.layer.layerMask
  82493. * @param name defines name for the texture
  82494. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  82495. * @param scene defines the hsoting scene
  82496. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  82497. * @returns a new AdvancedDynamicTexture
  82498. */
  82499. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  82500. }
  82501. }
  82502. declare module BABYLON.GUI {
  82503. /**
  82504. * Root class used for all 2D controls
  82505. * @see https://doc.babylonjs.com/how_to/gui#controls
  82506. */
  82507. export class Control {
  82508. /** defines the name of the control */
  82509. name?: string | undefined;
  82510. /**
  82511. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  82512. */
  82513. static AllowAlphaInheritance: boolean;
  82514. private _alpha;
  82515. private _alphaSet;
  82516. private _zIndex;
  82517. /** @hidden */
  82518. _host: AdvancedDynamicTexture;
  82519. /** Gets or sets the control parent */
  82520. parent: BABYLON.Nullable<Container>;
  82521. /** @hidden */
  82522. _currentMeasure: Measure;
  82523. private _fontFamily;
  82524. private _fontStyle;
  82525. private _fontWeight;
  82526. private _fontSize;
  82527. private _font;
  82528. /** @hidden */
  82529. _width: ValueAndUnit;
  82530. /** @hidden */
  82531. _height: ValueAndUnit;
  82532. /** @hidden */
  82533. protected _fontOffset: {
  82534. ascent: number;
  82535. height: number;
  82536. descent: number;
  82537. };
  82538. private _color;
  82539. private _style;
  82540. private _styleObserver;
  82541. /** @hidden */
  82542. protected _horizontalAlignment: number;
  82543. /** @hidden */
  82544. protected _verticalAlignment: number;
  82545. /** @hidden */
  82546. protected _isDirty: boolean;
  82547. /** @hidden */
  82548. protected _wasDirty: boolean;
  82549. /** @hidden */
  82550. _tempParentMeasure: Measure;
  82551. /** @hidden */
  82552. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  82553. /** @hidden */
  82554. protected _cachedParentMeasure: Measure;
  82555. private _paddingLeft;
  82556. private _paddingRight;
  82557. private _paddingTop;
  82558. private _paddingBottom;
  82559. /** @hidden */
  82560. _left: ValueAndUnit;
  82561. /** @hidden */
  82562. _top: ValueAndUnit;
  82563. private _scaleX;
  82564. private _scaleY;
  82565. private _rotation;
  82566. private _transformCenterX;
  82567. private _transformCenterY;
  82568. /** @hidden */
  82569. _transformMatrix: Matrix2D;
  82570. /** @hidden */
  82571. protected _invertTransformMatrix: Matrix2D;
  82572. /** @hidden */
  82573. protected _transformedPosition: BABYLON.Vector2;
  82574. private _isMatrixDirty;
  82575. private _cachedOffsetX;
  82576. private _cachedOffsetY;
  82577. private _isVisible;
  82578. private _isHighlighted;
  82579. /** @hidden */
  82580. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  82581. private _fontSet;
  82582. private _dummyVector2;
  82583. private _downCount;
  82584. private _enterCount;
  82585. private _doNotRender;
  82586. private _downPointerIds;
  82587. protected _isEnabled: boolean;
  82588. protected _disabledColor: string;
  82589. protected _disabledColorItem: string;
  82590. /** @hidden */
  82591. protected _rebuildLayout: boolean;
  82592. /** @hidden */
  82593. _customData: any;
  82594. /** @hidden */
  82595. _isClipped: boolean;
  82596. /** @hidden */
  82597. _automaticSize: boolean;
  82598. /** @hidden */
  82599. _tag: any;
  82600. /**
  82601. * 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
  82602. */
  82603. uniqueId: number;
  82604. /**
  82605. * Gets or sets an object used to store user defined information for the node
  82606. */
  82607. metadata: any;
  82608. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  82609. isHitTestVisible: boolean;
  82610. /** Gets or sets a boolean indicating if the control can block pointer events */
  82611. isPointerBlocker: boolean;
  82612. /** Gets or sets a boolean indicating if the control can be focusable */
  82613. isFocusInvisible: boolean;
  82614. /**
  82615. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  82616. * 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
  82617. */
  82618. clipChildren: boolean;
  82619. /**
  82620. * Gets or sets a boolean indicating that control content must be clipped
  82621. * 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
  82622. */
  82623. clipContent: boolean;
  82624. /**
  82625. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  82626. */
  82627. useBitmapCache: boolean;
  82628. private _cacheData;
  82629. private _shadowOffsetX;
  82630. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  82631. get shadowOffsetX(): number;
  82632. set shadowOffsetX(value: number);
  82633. private _shadowOffsetY;
  82634. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  82635. get shadowOffsetY(): number;
  82636. set shadowOffsetY(value: number);
  82637. private _shadowBlur;
  82638. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  82639. get shadowBlur(): number;
  82640. set shadowBlur(value: number);
  82641. private _shadowColor;
  82642. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  82643. get shadowColor(): string;
  82644. set shadowColor(value: string);
  82645. /** Gets or sets the cursor to use when the control is hovered */
  82646. hoverCursor: string;
  82647. /** @hidden */
  82648. protected _linkOffsetX: ValueAndUnit;
  82649. /** @hidden */
  82650. protected _linkOffsetY: ValueAndUnit;
  82651. /** Gets the control type name */
  82652. get typeName(): string;
  82653. /**
  82654. * Get the current class name of the control.
  82655. * @returns current class name
  82656. */
  82657. getClassName(): string;
  82658. /**
  82659. * An event triggered when pointer wheel is scrolled
  82660. */
  82661. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  82662. /**
  82663. * An event triggered when the pointer move over the control.
  82664. */
  82665. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  82666. /**
  82667. * An event triggered when the pointer move out of the control.
  82668. */
  82669. onPointerOutObservable: BABYLON.Observable<Control>;
  82670. /**
  82671. * An event triggered when the pointer taps the control
  82672. */
  82673. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  82674. /**
  82675. * An event triggered when pointer up
  82676. */
  82677. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  82678. /**
  82679. * An event triggered when a control is clicked on
  82680. */
  82681. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  82682. /**
  82683. * An event triggered when pointer enters the control
  82684. */
  82685. onPointerEnterObservable: BABYLON.Observable<Control>;
  82686. /**
  82687. * An event triggered when the control is marked as dirty
  82688. */
  82689. onDirtyObservable: BABYLON.Observable<Control>;
  82690. /**
  82691. * An event triggered before drawing the control
  82692. */
  82693. onBeforeDrawObservable: BABYLON.Observable<Control>;
  82694. /**
  82695. * An event triggered after the control was drawn
  82696. */
  82697. onAfterDrawObservable: BABYLON.Observable<Control>;
  82698. /**
  82699. * An event triggered when the control has been disposed
  82700. */
  82701. onDisposeObservable: BABYLON.Observable<Control>;
  82702. /**
  82703. * Get the hosting AdvancedDynamicTexture
  82704. */
  82705. get host(): AdvancedDynamicTexture;
  82706. /** Gets or set information about font offsets (used to render and align text) */
  82707. get fontOffset(): {
  82708. ascent: number;
  82709. height: number;
  82710. descent: number;
  82711. };
  82712. set fontOffset(offset: {
  82713. ascent: number;
  82714. height: number;
  82715. descent: number;
  82716. });
  82717. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  82718. get alpha(): number;
  82719. set alpha(value: number);
  82720. /**
  82721. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  82722. */
  82723. get isHighlighted(): boolean;
  82724. set isHighlighted(value: boolean);
  82725. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  82726. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82727. */
  82728. get scaleX(): number;
  82729. set scaleX(value: number);
  82730. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  82731. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82732. */
  82733. get scaleY(): number;
  82734. set scaleY(value: number);
  82735. /** Gets or sets the rotation angle (0 by default)
  82736. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82737. */
  82738. get rotation(): number;
  82739. set rotation(value: number);
  82740. /** Gets or sets the transformation center on Y axis (0 by default)
  82741. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82742. */
  82743. get transformCenterY(): number;
  82744. set transformCenterY(value: number);
  82745. /** Gets or sets the transformation center on X axis (0 by default)
  82746. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82747. */
  82748. get transformCenterX(): number;
  82749. set transformCenterX(value: number);
  82750. /**
  82751. * Gets or sets the horizontal alignment
  82752. * @see https://doc.babylonjs.com/how_to/gui#alignments
  82753. */
  82754. get horizontalAlignment(): number;
  82755. set horizontalAlignment(value: number);
  82756. /**
  82757. * Gets or sets the vertical alignment
  82758. * @see https://doc.babylonjs.com/how_to/gui#alignments
  82759. */
  82760. get verticalAlignment(): number;
  82761. set verticalAlignment(value: number);
  82762. /**
  82763. * Gets or sets a fixed ratio for this control.
  82764. * When different from 0, the ratio is used to compute the "second" dimension.
  82765. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  82766. * second dimension is computed as first dimension * fixedRatio
  82767. */
  82768. fixedRatio: number;
  82769. private _fixedRatioMasterIsWidth;
  82770. /**
  82771. * Gets or sets control width
  82772. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82773. */
  82774. get width(): string | number;
  82775. set width(value: string | number);
  82776. /**
  82777. * Gets or sets the control width in pixel
  82778. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82779. */
  82780. get widthInPixels(): number;
  82781. set widthInPixels(value: number);
  82782. /**
  82783. * Gets or sets control height
  82784. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82785. */
  82786. get height(): string | number;
  82787. set height(value: string | number);
  82788. /**
  82789. * Gets or sets control height in pixel
  82790. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82791. */
  82792. get heightInPixels(): number;
  82793. set heightInPixels(value: number);
  82794. /** Gets or set font family */
  82795. get fontFamily(): string;
  82796. set fontFamily(value: string);
  82797. /** Gets or sets font style */
  82798. get fontStyle(): string;
  82799. set fontStyle(value: string);
  82800. /** Gets or sets font weight */
  82801. get fontWeight(): string;
  82802. set fontWeight(value: string);
  82803. /**
  82804. * Gets or sets style
  82805. * @see https://doc.babylonjs.com/how_to/gui#styles
  82806. */
  82807. get style(): BABYLON.Nullable<Style>;
  82808. set style(value: BABYLON.Nullable<Style>);
  82809. /** @hidden */
  82810. get _isFontSizeInPercentage(): boolean;
  82811. /** Gets or sets font size in pixels */
  82812. get fontSizeInPixels(): number;
  82813. set fontSizeInPixels(value: number);
  82814. /** Gets or sets font size */
  82815. get fontSize(): string | number;
  82816. set fontSize(value: string | number);
  82817. /** Gets or sets foreground color */
  82818. get color(): string;
  82819. set color(value: string);
  82820. /** Gets or sets z index which is used to reorder controls on the z axis */
  82821. get zIndex(): number;
  82822. set zIndex(value: number);
  82823. /** Gets or sets a boolean indicating if the control can be rendered */
  82824. get notRenderable(): boolean;
  82825. set notRenderable(value: boolean);
  82826. /** Gets or sets a boolean indicating if the control is visible */
  82827. get isVisible(): boolean;
  82828. set isVisible(value: boolean);
  82829. /** Gets a boolean indicating that the control needs to update its rendering */
  82830. get isDirty(): boolean;
  82831. /**
  82832. * Gets the current linked mesh (or null if none)
  82833. */
  82834. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  82835. /**
  82836. * Gets or sets a value indicating the padding to use on the left of the control
  82837. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82838. */
  82839. get paddingLeft(): string | number;
  82840. set paddingLeft(value: string | number);
  82841. /**
  82842. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  82843. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82844. */
  82845. get paddingLeftInPixels(): number;
  82846. set paddingLeftInPixels(value: number);
  82847. /**
  82848. * Gets or sets a value indicating the padding to use on the right of the control
  82849. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82850. */
  82851. get paddingRight(): string | number;
  82852. set paddingRight(value: string | number);
  82853. /**
  82854. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  82855. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82856. */
  82857. get paddingRightInPixels(): number;
  82858. set paddingRightInPixels(value: number);
  82859. /**
  82860. * Gets or sets a value indicating the padding to use on the top of the control
  82861. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82862. */
  82863. get paddingTop(): string | number;
  82864. set paddingTop(value: string | number);
  82865. /**
  82866. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  82867. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82868. */
  82869. get paddingTopInPixels(): number;
  82870. set paddingTopInPixels(value: number);
  82871. /**
  82872. * Gets or sets a value indicating the padding to use on the bottom of the control
  82873. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82874. */
  82875. get paddingBottom(): string | number;
  82876. set paddingBottom(value: string | number);
  82877. /**
  82878. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  82879. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82880. */
  82881. get paddingBottomInPixels(): number;
  82882. set paddingBottomInPixels(value: number);
  82883. /**
  82884. * Gets or sets a value indicating the left coordinate of the control
  82885. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82886. */
  82887. get left(): string | number;
  82888. set left(value: string | number);
  82889. /**
  82890. * Gets or sets a value indicating the left coordinate in pixels of the control
  82891. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82892. */
  82893. get leftInPixels(): number;
  82894. set leftInPixels(value: number);
  82895. /**
  82896. * Gets or sets a value indicating the top coordinate of the control
  82897. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82898. */
  82899. get top(): string | number;
  82900. set top(value: string | number);
  82901. /**
  82902. * Gets or sets a value indicating the top coordinate in pixels of the control
  82903. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82904. */
  82905. get topInPixels(): number;
  82906. set topInPixels(value: number);
  82907. /**
  82908. * Gets or sets a value indicating the offset on X axis to the linked mesh
  82909. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82910. */
  82911. get linkOffsetX(): string | number;
  82912. set linkOffsetX(value: string | number);
  82913. /**
  82914. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  82915. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82916. */
  82917. get linkOffsetXInPixels(): number;
  82918. set linkOffsetXInPixels(value: number);
  82919. /**
  82920. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  82921. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82922. */
  82923. get linkOffsetY(): string | number;
  82924. set linkOffsetY(value: string | number);
  82925. /**
  82926. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  82927. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82928. */
  82929. get linkOffsetYInPixels(): number;
  82930. set linkOffsetYInPixels(value: number);
  82931. /** Gets the center coordinate on X axis */
  82932. get centerX(): number;
  82933. /** Gets the center coordinate on Y axis */
  82934. get centerY(): number;
  82935. /** Gets or sets if control is Enabled */
  82936. get isEnabled(): boolean;
  82937. set isEnabled(value: boolean);
  82938. /** Gets or sets background color of control if it's disabled */
  82939. get disabledColor(): string;
  82940. set disabledColor(value: string);
  82941. /** Gets or sets front color of control if it's disabled */
  82942. get disabledColorItem(): string;
  82943. set disabledColorItem(value: string);
  82944. /**
  82945. * Creates a new control
  82946. * @param name defines the name of the control
  82947. */
  82948. constructor(
  82949. /** defines the name of the control */
  82950. name?: string | undefined);
  82951. /** @hidden */
  82952. protected _getTypeName(): string;
  82953. /**
  82954. * Gets the first ascendant in the hierarchy of the given type
  82955. * @param className defines the required type
  82956. * @returns the ascendant or null if not found
  82957. */
  82958. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  82959. /** @hidden */
  82960. _resetFontCache(): void;
  82961. /**
  82962. * Determines if a container is an ascendant of the current control
  82963. * @param container defines the container to look for
  82964. * @returns true if the container is one of the ascendant of the control
  82965. */
  82966. isAscendant(container: Control): boolean;
  82967. /**
  82968. * Gets coordinates in local control space
  82969. * @param globalCoordinates defines the coordinates to transform
  82970. * @returns the new coordinates in local space
  82971. */
  82972. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  82973. /**
  82974. * Gets coordinates in local control space
  82975. * @param globalCoordinates defines the coordinates to transform
  82976. * @param result defines the target vector2 where to store the result
  82977. * @returns the current control
  82978. */
  82979. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  82980. /**
  82981. * Gets coordinates in parent local control space
  82982. * @param globalCoordinates defines the coordinates to transform
  82983. * @returns the new coordinates in parent local space
  82984. */
  82985. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  82986. /**
  82987. * Move the current control to a vector3 position projected onto the screen.
  82988. * @param position defines the target position
  82989. * @param scene defines the hosting scene
  82990. */
  82991. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  82992. /**
  82993. * Will store all controls that have this control as ascendant in a given array
  82994. * @param results defines the array where to store the descendants
  82995. * @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
  82996. * @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
  82997. */
  82998. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  82999. /**
  83000. * Will return all controls that have this control as ascendant
  83001. * @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
  83002. * @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
  83003. * @return all child controls
  83004. */
  83005. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83006. /**
  83007. * Link current control with a target mesh
  83008. * @param mesh defines the mesh to link with
  83009. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83010. */
  83011. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  83012. /**
  83013. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  83014. * @param { string | number} paddingTop - The value of the top padding.
  83015. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  83016. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  83017. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  83018. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83019. */
  83020. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  83021. /**
  83022. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  83023. * @param { number} paddingTop - The value in pixels of the top padding.
  83024. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  83025. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  83026. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  83027. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83028. */
  83029. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  83030. /** @hidden */
  83031. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  83032. /** @hidden */
  83033. _offsetLeft(offset: number): void;
  83034. /** @hidden */
  83035. _offsetTop(offset: number): void;
  83036. /** @hidden */
  83037. _markMatrixAsDirty(): void;
  83038. /** @hidden */
  83039. _flagDescendantsAsMatrixDirty(): void;
  83040. /** @hidden */
  83041. _intersectsRect(rect: Measure): boolean;
  83042. /** @hidden */
  83043. protected invalidateRect(): void;
  83044. /** @hidden */
  83045. _markAsDirty(force?: boolean): void;
  83046. /** @hidden */
  83047. _markAllAsDirty(): void;
  83048. /** @hidden */
  83049. _link(host: AdvancedDynamicTexture): void;
  83050. /** @hidden */
  83051. protected _transform(context?: CanvasRenderingContext2D): void;
  83052. /** @hidden */
  83053. _renderHighlight(context: CanvasRenderingContext2D): void;
  83054. /** @hidden */
  83055. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  83056. /** @hidden */
  83057. protected _applyStates(context: CanvasRenderingContext2D): void;
  83058. /** @hidden */
  83059. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83060. /** @hidden */
  83061. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83062. protected _evaluateClippingState(parentMeasure: Measure): void;
  83063. /** @hidden */
  83064. _measure(): void;
  83065. /** @hidden */
  83066. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83067. /** @hidden */
  83068. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83069. /** @hidden */
  83070. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83071. /** @hidden */
  83072. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83073. private static _ClipMeasure;
  83074. private _tmpMeasureA;
  83075. private _clip;
  83076. /** @hidden */
  83077. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  83078. /** @hidden */
  83079. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83080. /**
  83081. * Tests if a given coordinates belong to the current control
  83082. * @param x defines x coordinate to test
  83083. * @param y defines y coordinate to test
  83084. * @returns true if the coordinates are inside the control
  83085. */
  83086. contains(x: number, y: number): boolean;
  83087. /** @hidden */
  83088. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83089. /** @hidden */
  83090. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  83091. /** @hidden */
  83092. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83093. /** @hidden */
  83094. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  83095. /** @hidden */
  83096. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83097. /** @hidden */
  83098. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  83099. /** @hidden */
  83100. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  83101. /** @hidden */
  83102. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  83103. /** @hidden */
  83104. _onCanvasBlur(): void;
  83105. /** @hidden */
  83106. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83107. private _prepareFont;
  83108. /**
  83109. * Serializes the current control
  83110. * @param serializationObject defined the JSON serialized object
  83111. */
  83112. serialize(serializationObject: any): void;
  83113. /** @hidden */
  83114. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83115. /** Releases associated resources */
  83116. dispose(): void;
  83117. private static _HORIZONTAL_ALIGNMENT_LEFT;
  83118. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  83119. private static _HORIZONTAL_ALIGNMENT_CENTER;
  83120. private static _VERTICAL_ALIGNMENT_TOP;
  83121. private static _VERTICAL_ALIGNMENT_BOTTOM;
  83122. private static _VERTICAL_ALIGNMENT_CENTER;
  83123. /** HORIZONTAL_ALIGNMENT_LEFT */
  83124. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  83125. /** HORIZONTAL_ALIGNMENT_RIGHT */
  83126. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  83127. /** HORIZONTAL_ALIGNMENT_CENTER */
  83128. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  83129. /** VERTICAL_ALIGNMENT_TOP */
  83130. static get VERTICAL_ALIGNMENT_TOP(): number;
  83131. /** VERTICAL_ALIGNMENT_BOTTOM */
  83132. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  83133. /** VERTICAL_ALIGNMENT_CENTER */
  83134. static get VERTICAL_ALIGNMENT_CENTER(): number;
  83135. private static _FontHeightSizes;
  83136. /** @hidden */
  83137. static _GetFontOffset(font: string): {
  83138. ascent: number;
  83139. height: number;
  83140. descent: number;
  83141. };
  83142. /**
  83143. * Creates a Control from parsed data
  83144. * @param serializedObject defines parsed data
  83145. * @param host defines the hosting AdvancedDynamicTexture
  83146. * @returns a new Control
  83147. */
  83148. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  83149. /**
  83150. * Creates a stack panel that can be used to render headers
  83151. * @param control defines the control to associate with the header
  83152. * @param text defines the text of the header
  83153. * @param size defines the size of the header
  83154. * @param options defines options used to configure the header
  83155. * @returns a new StackPanel
  83156. * @ignore
  83157. * @hidden
  83158. */
  83159. static AddHeader: (control: Control, text: string, size: string | number, options: {
  83160. isHorizontal: boolean;
  83161. controlFirst: boolean;
  83162. }) => any;
  83163. /** @hidden */
  83164. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  83165. }
  83166. }
  83167. declare module BABYLON.GUI {
  83168. /**
  83169. * Root class for 2D containers
  83170. * @see https://doc.babylonjs.com/how_to/gui#containers
  83171. */
  83172. export class Container extends Control {
  83173. name?: string | undefined;
  83174. /** @hidden */
  83175. _children: Control[];
  83176. /** @hidden */
  83177. protected _measureForChildren: Measure;
  83178. /** @hidden */
  83179. protected _background: string;
  83180. /** @hidden */
  83181. protected _adaptWidthToChildren: boolean;
  83182. /** @hidden */
  83183. protected _adaptHeightToChildren: boolean;
  83184. /**
  83185. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  83186. */
  83187. logLayoutCycleErrors: boolean;
  83188. /**
  83189. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  83190. */
  83191. maxLayoutCycle: number;
  83192. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  83193. get adaptHeightToChildren(): boolean;
  83194. set adaptHeightToChildren(value: boolean);
  83195. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  83196. get adaptWidthToChildren(): boolean;
  83197. set adaptWidthToChildren(value: boolean);
  83198. /** Gets or sets background color */
  83199. get background(): string;
  83200. set background(value: string);
  83201. /** Gets the list of children */
  83202. get children(): Control[];
  83203. /**
  83204. * Creates a new Container
  83205. * @param name defines the name of the container
  83206. */
  83207. constructor(name?: string | undefined);
  83208. protected _getTypeName(): string;
  83209. _flagDescendantsAsMatrixDirty(): void;
  83210. /**
  83211. * Gets a child using its name
  83212. * @param name defines the child name to look for
  83213. * @returns the child control if found
  83214. */
  83215. getChildByName(name: string): BABYLON.Nullable<Control>;
  83216. /**
  83217. * Gets a child using its type and its name
  83218. * @param name defines the child name to look for
  83219. * @param type defines the child type to look for
  83220. * @returns the child control if found
  83221. */
  83222. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  83223. /**
  83224. * Search for a specific control in children
  83225. * @param control defines the control to look for
  83226. * @returns true if the control is in child list
  83227. */
  83228. containsControl(control: Control): boolean;
  83229. /**
  83230. * Adds a new control to the current container
  83231. * @param control defines the control to add
  83232. * @returns the current container
  83233. */
  83234. addControl(control: BABYLON.Nullable<Control>): Container;
  83235. /**
  83236. * Removes all controls from the current container
  83237. * @returns the current container
  83238. */
  83239. clearControls(): Container;
  83240. /**
  83241. * Removes a control from the current container
  83242. * @param control defines the control to remove
  83243. * @returns the current container
  83244. */
  83245. removeControl(control: Control): Container;
  83246. /** @hidden */
  83247. _reOrderControl(control: Control): void;
  83248. /** @hidden */
  83249. _offsetLeft(offset: number): void;
  83250. /** @hidden */
  83251. _offsetTop(offset: number): void;
  83252. /** @hidden */
  83253. _markAllAsDirty(): void;
  83254. /** @hidden */
  83255. protected _localDraw(context: CanvasRenderingContext2D): void;
  83256. /** @hidden */
  83257. _link(host: AdvancedDynamicTexture): void;
  83258. /** @hidden */
  83259. protected _beforeLayout(): void;
  83260. /** @hidden */
  83261. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83262. /** @hidden */
  83263. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83264. protected _postMeasure(): void;
  83265. /** @hidden */
  83266. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  83267. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83268. /** @hidden */
  83269. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83270. /** @hidden */
  83271. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83272. /**
  83273. * Serializes the current control
  83274. * @param serializationObject defined the JSON serialized object
  83275. */
  83276. serialize(serializationObject: any): void;
  83277. /** Releases associated resources */
  83278. dispose(): void;
  83279. /** @hidden */
  83280. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83281. }
  83282. }
  83283. declare module BABYLON.GUI {
  83284. /** Class used to create rectangle container */
  83285. export class Rectangle extends Container {
  83286. name?: string | undefined;
  83287. private _thickness;
  83288. private _cornerRadius;
  83289. /** Gets or sets border thickness */
  83290. get thickness(): number;
  83291. set thickness(value: number);
  83292. /** Gets or sets the corner radius angle */
  83293. get cornerRadius(): number;
  83294. set cornerRadius(value: number);
  83295. /**
  83296. * Creates a new Rectangle
  83297. * @param name defines the control name
  83298. */
  83299. constructor(name?: string | undefined);
  83300. protected _getTypeName(): string;
  83301. protected _localDraw(context: CanvasRenderingContext2D): void;
  83302. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83303. private _drawRoundedRect;
  83304. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83305. }
  83306. }
  83307. declare module BABYLON.GUI {
  83308. /**
  83309. * Enum that determines the text-wrapping mode to use.
  83310. */
  83311. export enum TextWrapping {
  83312. /**
  83313. * Clip the text when it's larger than Control.width; this is the default mode.
  83314. */
  83315. Clip = 0,
  83316. /**
  83317. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  83318. */
  83319. WordWrap = 1,
  83320. /**
  83321. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  83322. */
  83323. Ellipsis = 2
  83324. }
  83325. /**
  83326. * Class used to create text block control
  83327. */
  83328. export class TextBlock extends Control {
  83329. /**
  83330. * Defines the name of the control
  83331. */
  83332. name?: string | undefined;
  83333. private _text;
  83334. private _textWrapping;
  83335. private _textHorizontalAlignment;
  83336. private _textVerticalAlignment;
  83337. private _lines;
  83338. private _resizeToFit;
  83339. private _lineSpacing;
  83340. private _outlineWidth;
  83341. private _outlineColor;
  83342. private _underline;
  83343. private _lineThrough;
  83344. /**
  83345. * An event triggered after the text is changed
  83346. */
  83347. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  83348. /**
  83349. * An event triggered after the text was broken up into lines
  83350. */
  83351. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  83352. /**
  83353. * Function used to split a string into words. By default, a string is split at each space character found
  83354. */
  83355. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  83356. /**
  83357. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  83358. */
  83359. get lines(): any[];
  83360. /**
  83361. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83362. */
  83363. get resizeToFit(): boolean;
  83364. /**
  83365. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83366. */
  83367. set resizeToFit(value: boolean);
  83368. /**
  83369. * Gets or sets a boolean indicating if text must be wrapped
  83370. */
  83371. get textWrapping(): TextWrapping | boolean;
  83372. /**
  83373. * Gets or sets a boolean indicating if text must be wrapped
  83374. */
  83375. set textWrapping(value: TextWrapping | boolean);
  83376. /**
  83377. * Gets or sets text to display
  83378. */
  83379. get text(): string;
  83380. /**
  83381. * Gets or sets text to display
  83382. */
  83383. set text(value: string);
  83384. /**
  83385. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83386. */
  83387. get textHorizontalAlignment(): number;
  83388. /**
  83389. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83390. */
  83391. set textHorizontalAlignment(value: number);
  83392. /**
  83393. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83394. */
  83395. get textVerticalAlignment(): number;
  83396. /**
  83397. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83398. */
  83399. set textVerticalAlignment(value: number);
  83400. /**
  83401. * Gets or sets line spacing value
  83402. */
  83403. set lineSpacing(value: string | number);
  83404. /**
  83405. * Gets or sets line spacing value
  83406. */
  83407. get lineSpacing(): string | number;
  83408. /**
  83409. * Gets or sets outlineWidth of the text to display
  83410. */
  83411. get outlineWidth(): number;
  83412. /**
  83413. * Gets or sets outlineWidth of the text to display
  83414. */
  83415. set outlineWidth(value: number);
  83416. /**
  83417. * Gets or sets a boolean indicating that text must have underline
  83418. */
  83419. get underline(): boolean;
  83420. /**
  83421. * Gets or sets a boolean indicating that text must have underline
  83422. */
  83423. set underline(value: boolean);
  83424. /**
  83425. * Gets or sets an boolean indicating that text must be crossed out
  83426. */
  83427. get lineThrough(): boolean;
  83428. /**
  83429. * Gets or sets an boolean indicating that text must be crossed out
  83430. */
  83431. set lineThrough(value: boolean);
  83432. /**
  83433. * Gets or sets outlineColor of the text to display
  83434. */
  83435. get outlineColor(): string;
  83436. /**
  83437. * Gets or sets outlineColor of the text to display
  83438. */
  83439. set outlineColor(value: string);
  83440. /**
  83441. * Creates a new TextBlock object
  83442. * @param name defines the name of the control
  83443. * @param text defines the text to display (emptry string by default)
  83444. */
  83445. constructor(
  83446. /**
  83447. * Defines the name of the control
  83448. */
  83449. name?: string | undefined, text?: string);
  83450. protected _getTypeName(): string;
  83451. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83452. private _drawText;
  83453. /** @hidden */
  83454. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83455. protected _applyStates(context: CanvasRenderingContext2D): void;
  83456. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  83457. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  83458. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  83459. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  83460. protected _renderLines(context: CanvasRenderingContext2D): void;
  83461. /**
  83462. * Given a width constraint applied on the text block, find the expected height
  83463. * @returns expected height
  83464. */
  83465. computeExpectedHeight(): number;
  83466. dispose(): void;
  83467. }
  83468. }
  83469. declare module BABYLON.GUI {
  83470. /**
  83471. * Class used to create 2D images
  83472. */
  83473. export class Image extends Control {
  83474. name?: string | undefined;
  83475. private _workingCanvas;
  83476. private _domImage;
  83477. private _imageWidth;
  83478. private _imageHeight;
  83479. private _loaded;
  83480. private _stretch;
  83481. private _source;
  83482. private _autoScale;
  83483. private _sourceLeft;
  83484. private _sourceTop;
  83485. private _sourceWidth;
  83486. private _sourceHeight;
  83487. private _svgAttributesComputationCompleted;
  83488. private _isSVG;
  83489. private _cellWidth;
  83490. private _cellHeight;
  83491. private _cellId;
  83492. private _populateNinePatchSlicesFromImage;
  83493. private _sliceLeft;
  83494. private _sliceRight;
  83495. private _sliceTop;
  83496. private _sliceBottom;
  83497. private _detectPointerOnOpaqueOnly;
  83498. private _imageDataCache;
  83499. /**
  83500. * BABYLON.Observable notified when the content is loaded
  83501. */
  83502. onImageLoadedObservable: BABYLON.Observable<Image>;
  83503. /**
  83504. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  83505. */
  83506. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  83507. /**
  83508. * Gets a boolean indicating that the content is loaded
  83509. */
  83510. get isLoaded(): boolean;
  83511. /**
  83512. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  83513. */
  83514. get populateNinePatchSlicesFromImage(): boolean;
  83515. set populateNinePatchSlicesFromImage(value: boolean);
  83516. /**
  83517. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  83518. * Beware using this as this will comsume more memory as the image has to be stored twice
  83519. */
  83520. get detectPointerOnOpaqueOnly(): boolean;
  83521. set detectPointerOnOpaqueOnly(value: boolean);
  83522. /**
  83523. * Gets or sets the left value for slicing (9-patch)
  83524. */
  83525. get sliceLeft(): number;
  83526. set sliceLeft(value: number);
  83527. /**
  83528. * Gets or sets the right value for slicing (9-patch)
  83529. */
  83530. get sliceRight(): number;
  83531. set sliceRight(value: number);
  83532. /**
  83533. * Gets or sets the top value for slicing (9-patch)
  83534. */
  83535. get sliceTop(): number;
  83536. set sliceTop(value: number);
  83537. /**
  83538. * Gets or sets the bottom value for slicing (9-patch)
  83539. */
  83540. get sliceBottom(): number;
  83541. set sliceBottom(value: number);
  83542. /**
  83543. * Gets or sets the left coordinate in the source image
  83544. */
  83545. get sourceLeft(): number;
  83546. set sourceLeft(value: number);
  83547. /**
  83548. * Gets or sets the top coordinate in the source image
  83549. */
  83550. get sourceTop(): number;
  83551. set sourceTop(value: number);
  83552. /**
  83553. * Gets or sets the width to capture in the source image
  83554. */
  83555. get sourceWidth(): number;
  83556. set sourceWidth(value: number);
  83557. /**
  83558. * Gets or sets the height to capture in the source image
  83559. */
  83560. get sourceHeight(): number;
  83561. set sourceHeight(value: number);
  83562. /** Indicates if the format of the image is SVG */
  83563. get isSVG(): boolean;
  83564. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  83565. get svgAttributesComputationCompleted(): boolean;
  83566. /**
  83567. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  83568. * @see https://doc.babylonjs.com/how_to/gui#image
  83569. */
  83570. get autoScale(): boolean;
  83571. set autoScale(value: boolean);
  83572. /** Gets or sets the streching mode used by the image */
  83573. get stretch(): number;
  83574. set stretch(value: number);
  83575. /** @hidden */
  83576. _rotate90(n: number, preserveProperties?: boolean): Image;
  83577. private _handleRotationForSVGImage;
  83578. private _rotate90SourceProperties;
  83579. /**
  83580. * Gets or sets the internal DOM image used to render the control
  83581. */
  83582. set domImage(value: HTMLImageElement);
  83583. get domImage(): HTMLImageElement;
  83584. private _onImageLoaded;
  83585. private _extractNinePatchSliceDataFromImage;
  83586. /**
  83587. * Gets the image source url
  83588. */
  83589. get source(): BABYLON.Nullable<string>;
  83590. /**
  83591. * Gets or sets image source url
  83592. */
  83593. set source(value: BABYLON.Nullable<string>);
  83594. /**
  83595. * Checks for svg document with icon id present
  83596. */
  83597. private _svgCheck;
  83598. /**
  83599. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  83600. * given external svg file and icon id
  83601. */
  83602. private _getSVGAttribs;
  83603. /**
  83604. * Gets or sets the cell width to use when animation sheet is enabled
  83605. * @see https://doc.babylonjs.com/how_to/gui#image
  83606. */
  83607. get cellWidth(): number;
  83608. set cellWidth(value: number);
  83609. /**
  83610. * Gets or sets the cell height to use when animation sheet is enabled
  83611. * @see https://doc.babylonjs.com/how_to/gui#image
  83612. */
  83613. get cellHeight(): number;
  83614. set cellHeight(value: number);
  83615. /**
  83616. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  83617. * @see https://doc.babylonjs.com/how_to/gui#image
  83618. */
  83619. get cellId(): number;
  83620. set cellId(value: number);
  83621. /**
  83622. * Creates a new Image
  83623. * @param name defines the control name
  83624. * @param url defines the image url
  83625. */
  83626. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  83627. /**
  83628. * Tests if a given coordinates belong to the current control
  83629. * @param x defines x coordinate to test
  83630. * @param y defines y coordinate to test
  83631. * @returns true if the coordinates are inside the control
  83632. */
  83633. contains(x: number, y: number): boolean;
  83634. protected _getTypeName(): string;
  83635. /** Force the control to synchronize with its content */
  83636. synchronizeSizeWithContent(): void;
  83637. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83638. private _prepareWorkingCanvasForOpaqueDetection;
  83639. private _drawImage;
  83640. _draw(context: CanvasRenderingContext2D): void;
  83641. private _renderCornerPatch;
  83642. private _renderNinePatch;
  83643. dispose(): void;
  83644. /** STRETCH_NONE */
  83645. static readonly STRETCH_NONE: number;
  83646. /** STRETCH_FILL */
  83647. static readonly STRETCH_FILL: number;
  83648. /** STRETCH_UNIFORM */
  83649. static readonly STRETCH_UNIFORM: number;
  83650. /** STRETCH_EXTEND */
  83651. static readonly STRETCH_EXTEND: number;
  83652. /** NINE_PATCH */
  83653. static readonly STRETCH_NINE_PATCH: number;
  83654. }
  83655. }
  83656. declare module BABYLON.GUI {
  83657. /**
  83658. * Class used to create 2D buttons
  83659. */
  83660. export class Button extends Rectangle {
  83661. name?: string | undefined;
  83662. /**
  83663. * Function called to generate a pointer enter animation
  83664. */
  83665. pointerEnterAnimation: () => void;
  83666. /**
  83667. * Function called to generate a pointer out animation
  83668. */
  83669. pointerOutAnimation: () => void;
  83670. /**
  83671. * Function called to generate a pointer down animation
  83672. */
  83673. pointerDownAnimation: () => void;
  83674. /**
  83675. * Function called to generate a pointer up animation
  83676. */
  83677. pointerUpAnimation: () => void;
  83678. /**
  83679. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  83680. */
  83681. delegatePickingToChildren: boolean;
  83682. private _image;
  83683. /**
  83684. * Returns the image part of the button (if any)
  83685. */
  83686. get image(): BABYLON.Nullable<Image>;
  83687. private _textBlock;
  83688. /**
  83689. * Returns the image part of the button (if any)
  83690. */
  83691. get textBlock(): BABYLON.Nullable<TextBlock>;
  83692. /**
  83693. * Creates a new Button
  83694. * @param name defines the name of the button
  83695. */
  83696. constructor(name?: string | undefined);
  83697. protected _getTypeName(): string;
  83698. /** @hidden */
  83699. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83700. /** @hidden */
  83701. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83702. /** @hidden */
  83703. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  83704. /** @hidden */
  83705. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83706. /** @hidden */
  83707. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  83708. /**
  83709. * Creates a new button made with an image and a text
  83710. * @param name defines the name of the button
  83711. * @param text defines the text of the button
  83712. * @param imageUrl defines the url of the image
  83713. * @returns a new Button
  83714. */
  83715. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  83716. /**
  83717. * Creates a new button made with an image
  83718. * @param name defines the name of the button
  83719. * @param imageUrl defines the url of the image
  83720. * @returns a new Button
  83721. */
  83722. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  83723. /**
  83724. * Creates a new button made with a text
  83725. * @param name defines the name of the button
  83726. * @param text defines the text of the button
  83727. * @returns a new Button
  83728. */
  83729. static CreateSimpleButton(name: string, text: string): Button;
  83730. /**
  83731. * Creates a new button made with an image and a centered text
  83732. * @param name defines the name of the button
  83733. * @param text defines the text of the button
  83734. * @param imageUrl defines the url of the image
  83735. * @returns a new Button
  83736. */
  83737. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  83738. }
  83739. }
  83740. declare module BABYLON.GUI {
  83741. /**
  83742. * Class used to create a 2D stack panel container
  83743. */
  83744. export class StackPanel extends Container {
  83745. name?: string | undefined;
  83746. private _isVertical;
  83747. private _manualWidth;
  83748. private _manualHeight;
  83749. private _doNotTrackManualChanges;
  83750. /**
  83751. * Gets or sets a boolean indicating that layou warnings should be ignored
  83752. */
  83753. ignoreLayoutWarnings: boolean;
  83754. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  83755. get isVertical(): boolean;
  83756. set isVertical(value: boolean);
  83757. /**
  83758. * Gets or sets panel width.
  83759. * This value should not be set when in horizontal mode as it will be computed automatically
  83760. */
  83761. set width(value: string | number);
  83762. get width(): string | number;
  83763. /**
  83764. * Gets or sets panel height.
  83765. * This value should not be set when in vertical mode as it will be computed automatically
  83766. */
  83767. set height(value: string | number);
  83768. get height(): string | number;
  83769. /**
  83770. * Creates a new StackPanel
  83771. * @param name defines control name
  83772. */
  83773. constructor(name?: string | undefined);
  83774. protected _getTypeName(): string;
  83775. /** @hidden */
  83776. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83777. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83778. protected _postMeasure(): void;
  83779. /**
  83780. * Serializes the current control
  83781. * @param serializationObject defined the JSON serialized object
  83782. */
  83783. serialize(serializationObject: any): void;
  83784. /** @hidden */
  83785. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83786. }
  83787. }
  83788. declare module BABYLON.GUI {
  83789. /**
  83790. * Class used to represent a 2D checkbox
  83791. */
  83792. export class Checkbox extends Control {
  83793. name?: string | undefined;
  83794. private _isChecked;
  83795. private _background;
  83796. private _checkSizeRatio;
  83797. private _thickness;
  83798. /** Gets or sets border thickness */
  83799. get thickness(): number;
  83800. set thickness(value: number);
  83801. /**
  83802. * BABYLON.Observable raised when isChecked property changes
  83803. */
  83804. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  83805. /** Gets or sets a value indicating the ratio between overall size and check size */
  83806. get checkSizeRatio(): number;
  83807. set checkSizeRatio(value: number);
  83808. /** Gets or sets background color */
  83809. get background(): string;
  83810. set background(value: string);
  83811. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  83812. get isChecked(): boolean;
  83813. set isChecked(value: boolean);
  83814. /**
  83815. * Creates a new CheckBox
  83816. * @param name defines the control name
  83817. */
  83818. constructor(name?: string | undefined);
  83819. protected _getTypeName(): string;
  83820. /** @hidden */
  83821. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83822. /** @hidden */
  83823. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83824. /**
  83825. * Utility function to easily create a checkbox with a header
  83826. * @param title defines the label to use for the header
  83827. * @param onValueChanged defines the callback to call when value changes
  83828. * @returns a StackPanel containing the checkbox and a textBlock
  83829. */
  83830. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  83831. }
  83832. }
  83833. declare module BABYLON.GUI {
  83834. /**
  83835. * Class used to store key control properties
  83836. */
  83837. export class KeyPropertySet {
  83838. /** Width */
  83839. width?: string;
  83840. /** Height */
  83841. height?: string;
  83842. /** Left padding */
  83843. paddingLeft?: string;
  83844. /** Right padding */
  83845. paddingRight?: string;
  83846. /** Top padding */
  83847. paddingTop?: string;
  83848. /** Bottom padding */
  83849. paddingBottom?: string;
  83850. /** Foreground color */
  83851. color?: string;
  83852. /** Background color */
  83853. background?: string;
  83854. }
  83855. /**
  83856. * Class used to create virtual keyboard
  83857. */
  83858. export class VirtualKeyboard extends StackPanel {
  83859. /** BABYLON.Observable raised when a key is pressed */
  83860. onKeyPressObservable: BABYLON.Observable<string>;
  83861. /** Gets or sets default key button width */
  83862. defaultButtonWidth: string;
  83863. /** Gets or sets default key button height */
  83864. defaultButtonHeight: string;
  83865. /** Gets or sets default key button left padding */
  83866. defaultButtonPaddingLeft: string;
  83867. /** Gets or sets default key button right padding */
  83868. defaultButtonPaddingRight: string;
  83869. /** Gets or sets default key button top padding */
  83870. defaultButtonPaddingTop: string;
  83871. /** Gets or sets default key button bottom padding */
  83872. defaultButtonPaddingBottom: string;
  83873. /** Gets or sets default key button foreground color */
  83874. defaultButtonColor: string;
  83875. /** Gets or sets default key button background color */
  83876. defaultButtonBackground: string;
  83877. /** Gets or sets shift button foreground color */
  83878. shiftButtonColor: string;
  83879. /** Gets or sets shift button thickness*/
  83880. selectedShiftThickness: number;
  83881. /** Gets shift key state */
  83882. shiftState: number;
  83883. protected _getTypeName(): string;
  83884. private _createKey;
  83885. /**
  83886. * Adds a new row of keys
  83887. * @param keys defines the list of keys to add
  83888. * @param propertySets defines the associated property sets
  83889. */
  83890. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  83891. /**
  83892. * Set the shift key to a specific state
  83893. * @param shiftState defines the new shift state
  83894. */
  83895. applyShiftState(shiftState: number): void;
  83896. private _currentlyConnectedInputText;
  83897. private _connectedInputTexts;
  83898. private _onKeyPressObserver;
  83899. /** Gets the input text control currently attached to the keyboard */
  83900. get connectedInputText(): BABYLON.Nullable<InputText>;
  83901. /**
  83902. * Connects the keyboard with an input text control
  83903. *
  83904. * @param input defines the target control
  83905. */
  83906. connect(input: InputText): void;
  83907. /**
  83908. * Disconnects the keyboard from connected InputText controls
  83909. *
  83910. * @param input optionally defines a target control, otherwise all are disconnected
  83911. */
  83912. disconnect(input?: InputText): void;
  83913. private _removeConnectedInputObservables;
  83914. /**
  83915. * Release all resources
  83916. */
  83917. dispose(): void;
  83918. /**
  83919. * Creates a new keyboard using a default layout
  83920. *
  83921. * @param name defines control name
  83922. * @returns a new VirtualKeyboard
  83923. */
  83924. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  83925. }
  83926. }
  83927. declare module BABYLON.GUI {
  83928. /** @hidden */
  83929. export class TextWrapper {
  83930. private _text;
  83931. private _characters;
  83932. get text(): string;
  83933. set text(txt: string);
  83934. get length(): number;
  83935. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  83936. charAt(idx: number): string;
  83937. substr(from: number, length?: number): string;
  83938. substring(from: number, to?: number): string;
  83939. isWord(index: number): boolean;
  83940. }
  83941. }
  83942. declare module BABYLON.GUI {
  83943. /**
  83944. * Class used to create input text control
  83945. */
  83946. export class InputText extends Control implements IFocusableControl {
  83947. name?: string | undefined;
  83948. private _textWrapper;
  83949. private _placeholderText;
  83950. private _background;
  83951. private _focusedBackground;
  83952. private _focusedColor;
  83953. private _placeholderColor;
  83954. private _thickness;
  83955. private _margin;
  83956. private _autoStretchWidth;
  83957. private _maxWidth;
  83958. private _isFocused;
  83959. private _blinkTimeout;
  83960. private _blinkIsEven;
  83961. private _cursorOffset;
  83962. private _scrollLeft;
  83963. private _textWidth;
  83964. private _clickedCoordinate;
  83965. private _deadKey;
  83966. private _addKey;
  83967. private _currentKey;
  83968. private _isTextHighlightOn;
  83969. private _textHighlightColor;
  83970. private _highligherOpacity;
  83971. private _highlightedText;
  83972. private _startHighlightIndex;
  83973. private _endHighlightIndex;
  83974. private _cursorIndex;
  83975. private _onFocusSelectAll;
  83976. private _isPointerDown;
  83977. private _onClipboardObserver;
  83978. private _onPointerDblTapObserver;
  83979. /** @hidden */
  83980. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  83981. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  83982. promptMessage: string;
  83983. /** Force disable prompt on mobile device */
  83984. disableMobilePrompt: boolean;
  83985. /** BABYLON.Observable raised when the text changes */
  83986. onTextChangedObservable: BABYLON.Observable<InputText>;
  83987. /** BABYLON.Observable raised just before an entered character is to be added */
  83988. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  83989. /** BABYLON.Observable raised when the control gets the focus */
  83990. onFocusObservable: BABYLON.Observable<InputText>;
  83991. /** BABYLON.Observable raised when the control loses the focus */
  83992. onBlurObservable: BABYLON.Observable<InputText>;
  83993. /**Observable raised when the text is highlighted */
  83994. onTextHighlightObservable: BABYLON.Observable<InputText>;
  83995. /**Observable raised when copy event is triggered */
  83996. onTextCopyObservable: BABYLON.Observable<InputText>;
  83997. /** BABYLON.Observable raised when cut event is triggered */
  83998. onTextCutObservable: BABYLON.Observable<InputText>;
  83999. /** BABYLON.Observable raised when paste event is triggered */
  84000. onTextPasteObservable: BABYLON.Observable<InputText>;
  84001. /** BABYLON.Observable raised when a key event was processed */
  84002. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84003. /** Gets or sets the maximum width allowed by the control */
  84004. get maxWidth(): string | number;
  84005. /** Gets the maximum width allowed by the control in pixels */
  84006. get maxWidthInPixels(): number;
  84007. set maxWidth(value: string | number);
  84008. /** Gets or sets the text highlighter transparency; default: 0.4 */
  84009. get highligherOpacity(): number;
  84010. set highligherOpacity(value: number);
  84011. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  84012. get onFocusSelectAll(): boolean;
  84013. set onFocusSelectAll(value: boolean);
  84014. /** Gets or sets the text hightlight color */
  84015. get textHighlightColor(): string;
  84016. set textHighlightColor(value: string);
  84017. /** Gets or sets control margin */
  84018. get margin(): string;
  84019. /** Gets control margin in pixels */
  84020. get marginInPixels(): number;
  84021. set margin(value: string);
  84022. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  84023. get autoStretchWidth(): boolean;
  84024. set autoStretchWidth(value: boolean);
  84025. /** Gets or sets border thickness */
  84026. get thickness(): number;
  84027. set thickness(value: number);
  84028. /** Gets or sets the background color when focused */
  84029. get focusedBackground(): string;
  84030. set focusedBackground(value: string);
  84031. /** Gets or sets the background color when focused */
  84032. get focusedColor(): string;
  84033. set focusedColor(value: string);
  84034. /** Gets or sets the background color */
  84035. get background(): string;
  84036. set background(value: string);
  84037. /** Gets or sets the placeholder color */
  84038. get placeholderColor(): string;
  84039. set placeholderColor(value: string);
  84040. /** Gets or sets the text displayed when the control is empty */
  84041. get placeholderText(): string;
  84042. set placeholderText(value: string);
  84043. /** Gets or sets the dead key flag */
  84044. get deadKey(): boolean;
  84045. set deadKey(flag: boolean);
  84046. /** Gets or sets the highlight text */
  84047. get highlightedText(): string;
  84048. set highlightedText(text: string);
  84049. /** Gets or sets if the current key should be added */
  84050. get addKey(): boolean;
  84051. set addKey(flag: boolean);
  84052. /** Gets or sets the value of the current key being entered */
  84053. get currentKey(): string;
  84054. set currentKey(key: string);
  84055. /** Gets or sets the text displayed in the control */
  84056. get text(): string;
  84057. set text(value: string);
  84058. private _textHasChanged;
  84059. /** Gets or sets control width */
  84060. get width(): string | number;
  84061. set width(value: string | number);
  84062. /**
  84063. * Creates a new InputText
  84064. * @param name defines the control name
  84065. * @param text defines the text of the control
  84066. */
  84067. constructor(name?: string | undefined, text?: string);
  84068. /** @hidden */
  84069. onBlur(): void;
  84070. /** @hidden */
  84071. onFocus(): void;
  84072. /**
  84073. * Function to focus an inputText programmatically
  84074. */
  84075. focus(): void;
  84076. /**
  84077. * Function to unfocus an inputText programmatically
  84078. */
  84079. blur(): void;
  84080. protected _getTypeName(): string;
  84081. /**
  84082. * Function called to get the list of controls that should not steal the focus from this control
  84083. * @returns an array of controls
  84084. */
  84085. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84086. /** @hidden */
  84087. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  84088. /** @hidden */
  84089. private _updateValueFromCursorIndex;
  84090. /** @hidden */
  84091. private _processDblClick;
  84092. /** @hidden */
  84093. private _selectAllText;
  84094. /**
  84095. * Handles the keyboard event
  84096. * @param evt Defines the KeyboardEvent
  84097. */
  84098. processKeyboard(evt: KeyboardEvent): void;
  84099. /** @hidden */
  84100. private _onCopyText;
  84101. /** @hidden */
  84102. private _onCutText;
  84103. /** @hidden */
  84104. private _onPasteText;
  84105. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84106. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84107. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84108. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84109. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84110. dispose(): void;
  84111. }
  84112. }
  84113. declare module BABYLON.GUI {
  84114. /**
  84115. * Class used to create a 2D grid container
  84116. */
  84117. export class Grid extends Container {
  84118. name?: string | undefined;
  84119. private _rowDefinitions;
  84120. private _columnDefinitions;
  84121. private _cells;
  84122. private _childControls;
  84123. /**
  84124. * Gets the number of columns
  84125. */
  84126. get columnCount(): number;
  84127. /**
  84128. * Gets the number of rows
  84129. */
  84130. get rowCount(): number;
  84131. /** Gets the list of children */
  84132. get children(): Control[];
  84133. /** Gets the list of cells (e.g. the containers) */
  84134. get cells(): {
  84135. [key: string]: Container;
  84136. };
  84137. /**
  84138. * Gets the definition of a specific row
  84139. * @param index defines the index of the row
  84140. * @returns the row definition
  84141. */
  84142. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84143. /**
  84144. * Gets the definition of a specific column
  84145. * @param index defines the index of the column
  84146. * @returns the column definition
  84147. */
  84148. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84149. /**
  84150. * Adds a new row to the grid
  84151. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84152. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  84153. * @returns the current grid
  84154. */
  84155. addRowDefinition(height: number, isPixel?: boolean): Grid;
  84156. /**
  84157. * Adds a new column to the grid
  84158. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84159. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84160. * @returns the current grid
  84161. */
  84162. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  84163. /**
  84164. * Update a row definition
  84165. * @param index defines the index of the row to update
  84166. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84167. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  84168. * @returns the current grid
  84169. */
  84170. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  84171. /**
  84172. * Update a column definition
  84173. * @param index defines the index of the column to update
  84174. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84175. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84176. * @returns the current grid
  84177. */
  84178. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  84179. /**
  84180. * Gets the list of children stored in a specific cell
  84181. * @param row defines the row to check
  84182. * @param column defines the column to check
  84183. * @returns the list of controls
  84184. */
  84185. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  84186. /**
  84187. * Gets a string representing the child cell info (row x column)
  84188. * @param child defines the control to get info from
  84189. * @returns a string containing the child cell info (row x column)
  84190. */
  84191. getChildCellInfo(child: Control): string;
  84192. private _removeCell;
  84193. private _offsetCell;
  84194. /**
  84195. * Remove a column definition at specified index
  84196. * @param index defines the index of the column to remove
  84197. * @returns the current grid
  84198. */
  84199. removeColumnDefinition(index: number): Grid;
  84200. /**
  84201. * Remove a row definition at specified index
  84202. * @param index defines the index of the row to remove
  84203. * @returns the current grid
  84204. */
  84205. removeRowDefinition(index: number): Grid;
  84206. /**
  84207. * Adds a new control to the current grid
  84208. * @param control defines the control to add
  84209. * @param row defines the row where to add the control (0 by default)
  84210. * @param column defines the column where to add the control (0 by default)
  84211. * @returns the current grid
  84212. */
  84213. addControl(control: Control, row?: number, column?: number): Grid;
  84214. /**
  84215. * Removes a control from the current container
  84216. * @param control defines the control to remove
  84217. * @returns the current container
  84218. */
  84219. removeControl(control: Control): Container;
  84220. /**
  84221. * Creates a new Grid
  84222. * @param name defines control name
  84223. */
  84224. constructor(name?: string | undefined);
  84225. protected _getTypeName(): string;
  84226. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  84227. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84228. _flagDescendantsAsMatrixDirty(): void;
  84229. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84230. /** Releases associated resources */
  84231. dispose(): void;
  84232. }
  84233. }
  84234. declare module BABYLON.GUI {
  84235. /** Class used to create color pickers */
  84236. export class ColorPicker extends Control {
  84237. name?: string | undefined;
  84238. private static _Epsilon;
  84239. private _colorWheelCanvas;
  84240. private _value;
  84241. private _tmpColor;
  84242. private _pointerStartedOnSquare;
  84243. private _pointerStartedOnWheel;
  84244. private _squareLeft;
  84245. private _squareTop;
  84246. private _squareSize;
  84247. private _h;
  84248. private _s;
  84249. private _v;
  84250. private _lastPointerDownID;
  84251. /**
  84252. * BABYLON.Observable raised when the value changes
  84253. */
  84254. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  84255. /** Gets or sets the color of the color picker */
  84256. get value(): BABYLON.Color3;
  84257. set value(value: BABYLON.Color3);
  84258. /**
  84259. * Gets or sets control width
  84260. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84261. */
  84262. get width(): string | number;
  84263. set width(value: string | number);
  84264. /**
  84265. * Gets or sets control height
  84266. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84267. */
  84268. get height(): string | number;
  84269. /** Gets or sets control height */
  84270. set height(value: string | number);
  84271. /** Gets or sets control size */
  84272. get size(): string | number;
  84273. set size(value: string | number);
  84274. /**
  84275. * Creates a new ColorPicker
  84276. * @param name defines the control name
  84277. */
  84278. constructor(name?: string | undefined);
  84279. protected _getTypeName(): string;
  84280. /** @hidden */
  84281. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84282. private _updateSquareProps;
  84283. private _drawGradientSquare;
  84284. private _drawCircle;
  84285. private _createColorWheelCanvas;
  84286. /** @hidden */
  84287. _draw(context: CanvasRenderingContext2D): void;
  84288. private _pointerIsDown;
  84289. private _updateValueFromPointer;
  84290. private _isPointOnSquare;
  84291. private _isPointOnWheel;
  84292. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84293. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84294. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84295. _onCanvasBlur(): void;
  84296. /**
  84297. * This function expands the color picker by creating a color picker dialog with manual
  84298. * color value input and the ability to save colors into an array to be used later in
  84299. * subsequent launches of the dialogue.
  84300. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  84301. * @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.
  84302. * @returns picked color as a hex string and the saved colors array as hex strings.
  84303. */
  84304. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  84305. pickerWidth?: string;
  84306. pickerHeight?: string;
  84307. headerHeight?: string;
  84308. lastColor?: string;
  84309. swatchLimit?: number;
  84310. numSwatchesPerLine?: number;
  84311. savedColors?: Array<string>;
  84312. }): Promise<{
  84313. savedColors?: string[];
  84314. pickedColor: string;
  84315. }>;
  84316. }
  84317. }
  84318. declare module BABYLON.GUI {
  84319. /** Class used to create 2D ellipse containers */
  84320. export class Ellipse extends Container {
  84321. name?: string | undefined;
  84322. private _thickness;
  84323. /** Gets or sets border thickness */
  84324. get thickness(): number;
  84325. set thickness(value: number);
  84326. /**
  84327. * Creates a new Ellipse
  84328. * @param name defines the control name
  84329. */
  84330. constructor(name?: string | undefined);
  84331. protected _getTypeName(): string;
  84332. protected _localDraw(context: CanvasRenderingContext2D): void;
  84333. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84334. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84335. }
  84336. }
  84337. declare module BABYLON.GUI {
  84338. /**
  84339. * Class used to create a focusable button that can easily handle keyboard events
  84340. */
  84341. export class FocusableButton extends Button implements IFocusableControl {
  84342. name?: string | undefined;
  84343. /** Highlight color when button is focused */
  84344. focusedColor: BABYLON.Nullable<string>;
  84345. private _isFocused;
  84346. private _unfocusedColor;
  84347. /** BABYLON.Observable raised when the control gets the focus */
  84348. onFocusObservable: BABYLON.Observable<Button>;
  84349. /** BABYLON.Observable raised when the control loses the focus */
  84350. onBlurObservable: BABYLON.Observable<Button>;
  84351. /** BABYLON.Observable raised when a key event was processed */
  84352. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84353. constructor(name?: string | undefined);
  84354. /** @hidden */
  84355. onBlur(): void;
  84356. /** @hidden */
  84357. onFocus(): void;
  84358. /**
  84359. * Function called to get the list of controls that should not steal the focus from this control
  84360. * @returns an array of controls
  84361. */
  84362. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84363. /**
  84364. * Function to focus a button programmatically
  84365. */
  84366. focus(): void;
  84367. /**
  84368. * Function to unfocus a button programmatically
  84369. */
  84370. blur(): void;
  84371. /**
  84372. * Handles the keyboard event
  84373. * @param evt Defines the KeyboardEvent
  84374. */
  84375. processKeyboard(evt: KeyboardEvent): void;
  84376. /** @hidden */
  84377. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84378. /** @hidden */
  84379. displose(): void;
  84380. }
  84381. }
  84382. declare module BABYLON.GUI {
  84383. /**
  84384. * Class used to create a password control
  84385. */
  84386. export class InputPassword extends InputText {
  84387. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84388. }
  84389. }
  84390. declare module BABYLON.GUI {
  84391. /** Class used to render 2D lines */
  84392. export class Line extends Control {
  84393. name?: string | undefined;
  84394. private _lineWidth;
  84395. private _x1;
  84396. private _y1;
  84397. private _x2;
  84398. private _y2;
  84399. private _dash;
  84400. private _connectedControl;
  84401. private _connectedControlDirtyObserver;
  84402. /** Gets or sets the dash pattern */
  84403. get dash(): Array<number>;
  84404. set dash(value: Array<number>);
  84405. /** Gets or sets the control connected with the line end */
  84406. get connectedControl(): Control;
  84407. set connectedControl(value: Control);
  84408. /** Gets or sets start coordinates on X axis */
  84409. get x1(): string | number;
  84410. set x1(value: string | number);
  84411. /** Gets or sets start coordinates on Y axis */
  84412. get y1(): string | number;
  84413. set y1(value: string | number);
  84414. /** Gets or sets end coordinates on X axis */
  84415. get x2(): string | number;
  84416. set x2(value: string | number);
  84417. /** Gets or sets end coordinates on Y axis */
  84418. get y2(): string | number;
  84419. set y2(value: string | number);
  84420. /** Gets or sets line width */
  84421. get lineWidth(): number;
  84422. set lineWidth(value: number);
  84423. /** Gets or sets horizontal alignment */
  84424. set horizontalAlignment(value: number);
  84425. /** Gets or sets vertical alignment */
  84426. set verticalAlignment(value: number);
  84427. private get _effectiveX2();
  84428. private get _effectiveY2();
  84429. /**
  84430. * Creates a new Line
  84431. * @param name defines the control name
  84432. */
  84433. constructor(name?: string | undefined);
  84434. protected _getTypeName(): string;
  84435. _draw(context: CanvasRenderingContext2D): void;
  84436. _measure(): void;
  84437. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84438. /**
  84439. * Move one end of the line given 3D cartesian coordinates.
  84440. * @param position Targeted world position
  84441. * @param scene BABYLON.Scene
  84442. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84443. */
  84444. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  84445. /**
  84446. * Move one end of the line to a position in screen absolute space.
  84447. * @param projectedPosition Position in screen absolute space (X, Y)
  84448. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84449. */
  84450. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  84451. }
  84452. }
  84453. declare module BABYLON.GUI {
  84454. /**
  84455. * Class used to store a point for a MultiLine object.
  84456. * The point can be pure 2D coordinates, a mesh or a control
  84457. */
  84458. export class MultiLinePoint {
  84459. private _multiLine;
  84460. private _x;
  84461. private _y;
  84462. private _control;
  84463. private _mesh;
  84464. private _controlObserver;
  84465. private _meshObserver;
  84466. /** @hidden */
  84467. _point: BABYLON.Vector3;
  84468. /**
  84469. * Creates a new MultiLinePoint
  84470. * @param multiLine defines the source MultiLine object
  84471. */
  84472. constructor(multiLine: MultiLine);
  84473. /** Gets or sets x coordinate */
  84474. get x(): string | number;
  84475. set x(value: string | number);
  84476. /** Gets or sets y coordinate */
  84477. get y(): string | number;
  84478. set y(value: string | number);
  84479. /** Gets or sets the control associated with this point */
  84480. get control(): BABYLON.Nullable<Control>;
  84481. set control(value: BABYLON.Nullable<Control>);
  84482. /** Gets or sets the mesh associated with this point */
  84483. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  84484. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  84485. /** Resets links */
  84486. resetLinks(): void;
  84487. /**
  84488. * Gets a translation vector with Z component
  84489. * @returns the translation vector
  84490. */
  84491. translate(): BABYLON.Vector3;
  84492. private _translatePoint;
  84493. /** Release associated resources */
  84494. dispose(): void;
  84495. }
  84496. }
  84497. declare module BABYLON.GUI {
  84498. /**
  84499. * Class used to create multi line control
  84500. */
  84501. export class MultiLine extends Control {
  84502. name?: string | undefined;
  84503. private _lineWidth;
  84504. private _dash;
  84505. private _points;
  84506. private _minX;
  84507. private _minY;
  84508. private _maxX;
  84509. private _maxY;
  84510. /**
  84511. * Creates a new MultiLine
  84512. * @param name defines the control name
  84513. */
  84514. constructor(name?: string | undefined);
  84515. /** Gets or sets dash pattern */
  84516. get dash(): Array<number>;
  84517. set dash(value: Array<number>);
  84518. /**
  84519. * Gets point stored at specified index
  84520. * @param index defines the index to look for
  84521. * @returns the requested point if found
  84522. */
  84523. getAt(index: number): MultiLinePoint;
  84524. /** Function called when a point is updated */
  84525. onPointUpdate: () => void;
  84526. /**
  84527. * Adds new points to the point collection
  84528. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  84529. * @returns the list of created MultiLinePoint
  84530. */
  84531. add(...items: (AbstractMesh | Control | {
  84532. x: string | number;
  84533. y: string | number;
  84534. })[]): MultiLinePoint[];
  84535. /**
  84536. * Adds a new point to the point collection
  84537. * @param item defines the item (mesh, control or 2d coordiantes) to add
  84538. * @returns the created MultiLinePoint
  84539. */
  84540. push(item?: (AbstractMesh | Control | {
  84541. x: string | number;
  84542. y: string | number;
  84543. })): MultiLinePoint;
  84544. /**
  84545. * Remove a specific value or point from the active point collection
  84546. * @param value defines the value or point to remove
  84547. */
  84548. remove(value: number | MultiLinePoint): void;
  84549. /**
  84550. * Resets this object to initial state (no point)
  84551. */
  84552. reset(): void;
  84553. /**
  84554. * Resets all links
  84555. */
  84556. resetLinks(): void;
  84557. /** Gets or sets line width */
  84558. get lineWidth(): number;
  84559. set lineWidth(value: number);
  84560. set horizontalAlignment(value: number);
  84561. set verticalAlignment(value: number);
  84562. protected _getTypeName(): string;
  84563. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84564. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84565. _measure(): void;
  84566. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84567. dispose(): void;
  84568. }
  84569. }
  84570. declare module BABYLON.GUI {
  84571. /**
  84572. * Class used to create radio button controls
  84573. */
  84574. export class RadioButton extends Control {
  84575. name?: string | undefined;
  84576. private _isChecked;
  84577. private _background;
  84578. private _checkSizeRatio;
  84579. private _thickness;
  84580. /** Gets or sets border thickness */
  84581. get thickness(): number;
  84582. set thickness(value: number);
  84583. /** Gets or sets group name */
  84584. group: string;
  84585. /** BABYLON.Observable raised when isChecked is changed */
  84586. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84587. /** Gets or sets a value indicating the ratio between overall size and check size */
  84588. get checkSizeRatio(): number;
  84589. set checkSizeRatio(value: number);
  84590. /** Gets or sets background color */
  84591. get background(): string;
  84592. set background(value: string);
  84593. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84594. get isChecked(): boolean;
  84595. set isChecked(value: boolean);
  84596. /**
  84597. * Creates a new RadioButton
  84598. * @param name defines the control name
  84599. */
  84600. constructor(name?: string | undefined);
  84601. protected _getTypeName(): string;
  84602. _draw(context: CanvasRenderingContext2D): void;
  84603. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84604. /**
  84605. * Utility function to easily create a radio button with a header
  84606. * @param title defines the label to use for the header
  84607. * @param group defines the group to use for the radio button
  84608. * @param isChecked defines the initial state of the radio button
  84609. * @param onValueChanged defines the callback to call when value changes
  84610. * @returns a StackPanel containing the radio button and a textBlock
  84611. */
  84612. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  84613. }
  84614. }
  84615. declare module BABYLON.GUI {
  84616. /**
  84617. * Class used to create slider controls
  84618. */
  84619. export class BaseSlider extends Control {
  84620. name?: string | undefined;
  84621. protected _thumbWidth: ValueAndUnit;
  84622. private _minimum;
  84623. private _maximum;
  84624. private _value;
  84625. private _isVertical;
  84626. protected _barOffset: ValueAndUnit;
  84627. private _isThumbClamped;
  84628. protected _displayThumb: boolean;
  84629. private _step;
  84630. private _lastPointerDownID;
  84631. protected _effectiveBarOffset: number;
  84632. protected _renderLeft: number;
  84633. protected _renderTop: number;
  84634. protected _renderWidth: number;
  84635. protected _renderHeight: number;
  84636. protected _backgroundBoxLength: number;
  84637. protected _backgroundBoxThickness: number;
  84638. protected _effectiveThumbThickness: number;
  84639. /** BABYLON.Observable raised when the sldier value changes */
  84640. onValueChangedObservable: BABYLON.Observable<number>;
  84641. /** Gets or sets a boolean indicating if the thumb must be rendered */
  84642. get displayThumb(): boolean;
  84643. set displayThumb(value: boolean);
  84644. /** Gets or sets a step to apply to values (0 by default) */
  84645. get step(): number;
  84646. set step(value: number);
  84647. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  84648. get barOffset(): string | number;
  84649. /** Gets main bar offset in pixels*/
  84650. get barOffsetInPixels(): number;
  84651. set barOffset(value: string | number);
  84652. /** Gets or sets thumb width */
  84653. get thumbWidth(): string | number;
  84654. /** Gets thumb width in pixels */
  84655. get thumbWidthInPixels(): number;
  84656. set thumbWidth(value: string | number);
  84657. /** Gets or sets minimum value */
  84658. get minimum(): number;
  84659. set minimum(value: number);
  84660. /** Gets or sets maximum value */
  84661. get maximum(): number;
  84662. set maximum(value: number);
  84663. /** Gets or sets current value */
  84664. get value(): number;
  84665. set value(value: number);
  84666. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  84667. get isVertical(): boolean;
  84668. set isVertical(value: boolean);
  84669. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  84670. get isThumbClamped(): boolean;
  84671. set isThumbClamped(value: boolean);
  84672. /**
  84673. * Creates a new BaseSlider
  84674. * @param name defines the control name
  84675. */
  84676. constructor(name?: string | undefined);
  84677. protected _getTypeName(): string;
  84678. protected _getThumbPosition(): number;
  84679. protected _getThumbThickness(type: string): number;
  84680. protected _prepareRenderingData(type: string): void;
  84681. private _pointerIsDown;
  84682. /** @hidden */
  84683. protected _updateValueFromPointer(x: number, y: number): void;
  84684. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84685. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84686. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84687. _onCanvasBlur(): void;
  84688. }
  84689. }
  84690. declare module BABYLON.GUI {
  84691. /**
  84692. * Class used to create slider controls
  84693. */
  84694. export class Slider extends BaseSlider {
  84695. name?: string | undefined;
  84696. private _background;
  84697. private _borderColor;
  84698. private _thumbColor;
  84699. private _isThumbCircle;
  84700. protected _displayValueBar: boolean;
  84701. /** Gets or sets a boolean indicating if the value bar must be rendered */
  84702. get displayValueBar(): boolean;
  84703. set displayValueBar(value: boolean);
  84704. /** Gets or sets border color */
  84705. get borderColor(): string;
  84706. set borderColor(value: string);
  84707. /** Gets or sets background color */
  84708. get background(): string;
  84709. set background(value: string);
  84710. /** Gets or sets thumb's color */
  84711. get thumbColor(): string;
  84712. set thumbColor(value: string);
  84713. /** Gets or sets a boolean indicating if the thumb should be round or square */
  84714. get isThumbCircle(): boolean;
  84715. set isThumbCircle(value: boolean);
  84716. /**
  84717. * Creates a new Slider
  84718. * @param name defines the control name
  84719. */
  84720. constructor(name?: string | undefined);
  84721. protected _getTypeName(): string;
  84722. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84723. }
  84724. }
  84725. declare module BABYLON.GUI {
  84726. /** Class used to create a RadioGroup
  84727. * which contains groups of radio buttons
  84728. */
  84729. export class SelectorGroup {
  84730. /** name of SelectorGroup */
  84731. name: string;
  84732. private _groupPanel;
  84733. private _selectors;
  84734. private _groupHeader;
  84735. /**
  84736. * Creates a new SelectorGroup
  84737. * @param name of group, used as a group heading
  84738. */
  84739. constructor(
  84740. /** name of SelectorGroup */
  84741. name: string);
  84742. /** Gets the groupPanel of the SelectorGroup */
  84743. get groupPanel(): StackPanel;
  84744. /** Gets the selectors array */
  84745. get selectors(): StackPanel[];
  84746. /** Gets and sets the group header */
  84747. get header(): string;
  84748. set header(label: string);
  84749. /** @hidden */
  84750. private _addGroupHeader;
  84751. /** @hidden*/
  84752. _getSelector(selectorNb: number): StackPanel | undefined;
  84753. /** Removes the selector at the given position
  84754. * @param selectorNb the position of the selector within the group
  84755. */
  84756. removeSelector(selectorNb: number): void;
  84757. }
  84758. /** Class used to create a CheckboxGroup
  84759. * which contains groups of checkbox buttons
  84760. */
  84761. export class CheckboxGroup extends SelectorGroup {
  84762. /** Adds a checkbox as a control
  84763. * @param text is the label for the selector
  84764. * @param func is the function called when the Selector is checked
  84765. * @param checked is true when Selector is checked
  84766. */
  84767. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  84768. /** @hidden */
  84769. _setSelectorLabel(selectorNb: number, label: string): void;
  84770. /** @hidden */
  84771. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84772. /** @hidden */
  84773. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84774. /** @hidden */
  84775. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84776. }
  84777. /** Class used to create a RadioGroup
  84778. * which contains groups of radio buttons
  84779. */
  84780. export class RadioGroup extends SelectorGroup {
  84781. private _selectNb;
  84782. /** Adds a radio button as a control
  84783. * @param label is the label for the selector
  84784. * @param func is the function called when the Selector is checked
  84785. * @param checked is true when Selector is checked
  84786. */
  84787. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  84788. /** @hidden */
  84789. _setSelectorLabel(selectorNb: number, label: string): void;
  84790. /** @hidden */
  84791. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84792. /** @hidden */
  84793. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84794. /** @hidden */
  84795. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84796. }
  84797. /** Class used to create a SliderGroup
  84798. * which contains groups of slider buttons
  84799. */
  84800. export class SliderGroup extends SelectorGroup {
  84801. /**
  84802. * Adds a slider to the SelectorGroup
  84803. * @param label is the label for the SliderBar
  84804. * @param func is the function called when the Slider moves
  84805. * @param unit is a string describing the units used, eg degrees or metres
  84806. * @param min is the minimum value for the Slider
  84807. * @param max is the maximum value for the Slider
  84808. * @param value is the start value for the Slider between min and max
  84809. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  84810. */
  84811. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  84812. /** @hidden */
  84813. _setSelectorLabel(selectorNb: number, label: string): void;
  84814. /** @hidden */
  84815. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84816. /** @hidden */
  84817. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84818. /** @hidden */
  84819. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84820. }
  84821. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  84822. * @see https://doc.babylonjs.com/how_to/selector
  84823. */
  84824. export class SelectionPanel extends Rectangle {
  84825. /** name of SelectionPanel */
  84826. name: string;
  84827. /** an array of SelectionGroups */
  84828. groups: SelectorGroup[];
  84829. private _panel;
  84830. private _buttonColor;
  84831. private _buttonBackground;
  84832. private _headerColor;
  84833. private _barColor;
  84834. private _barHeight;
  84835. private _spacerHeight;
  84836. private _labelColor;
  84837. private _groups;
  84838. private _bars;
  84839. /**
  84840. * Creates a new SelectionPanel
  84841. * @param name of SelectionPanel
  84842. * @param groups is an array of SelectionGroups
  84843. */
  84844. constructor(
  84845. /** name of SelectionPanel */
  84846. name: string,
  84847. /** an array of SelectionGroups */
  84848. groups?: SelectorGroup[]);
  84849. protected _getTypeName(): string;
  84850. /** Gets the (stack) panel of the SelectionPanel */
  84851. get panel(): StackPanel;
  84852. /** Gets or sets the headerColor */
  84853. get headerColor(): string;
  84854. set headerColor(color: string);
  84855. private _setHeaderColor;
  84856. /** Gets or sets the button color */
  84857. get buttonColor(): string;
  84858. set buttonColor(color: string);
  84859. private _setbuttonColor;
  84860. /** Gets or sets the label color */
  84861. get labelColor(): string;
  84862. set labelColor(color: string);
  84863. private _setLabelColor;
  84864. /** Gets or sets the button background */
  84865. get buttonBackground(): string;
  84866. set buttonBackground(color: string);
  84867. private _setButtonBackground;
  84868. /** Gets or sets the color of separator bar */
  84869. get barColor(): string;
  84870. set barColor(color: string);
  84871. private _setBarColor;
  84872. /** Gets or sets the height of separator bar */
  84873. get barHeight(): string;
  84874. set barHeight(value: string);
  84875. private _setBarHeight;
  84876. /** Gets or sets the height of spacers*/
  84877. get spacerHeight(): string;
  84878. set spacerHeight(value: string);
  84879. private _setSpacerHeight;
  84880. /** Adds a bar between groups */
  84881. private _addSpacer;
  84882. /** Add a group to the selection panel
  84883. * @param group is the selector group to add
  84884. */
  84885. addGroup(group: SelectorGroup): void;
  84886. /** Remove the group from the given position
  84887. * @param groupNb is the position of the group in the list
  84888. */
  84889. removeGroup(groupNb: number): void;
  84890. /** Change a group header label
  84891. * @param label is the new group header label
  84892. * @param groupNb is the number of the group to relabel
  84893. * */
  84894. setHeaderName(label: string, groupNb: number): void;
  84895. /** Change selector label to the one given
  84896. * @param label is the new selector label
  84897. * @param groupNb is the number of the groupcontaining the selector
  84898. * @param selectorNb is the number of the selector within a group to relabel
  84899. * */
  84900. relabel(label: string, groupNb: number, selectorNb: number): void;
  84901. /** For a given group position remove the selector at the given position
  84902. * @param groupNb is the number of the group to remove the selector from
  84903. * @param selectorNb is the number of the selector within the group
  84904. */
  84905. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  84906. /** For a given group position of correct type add a checkbox button
  84907. * @param groupNb is the number of the group to remove the selector from
  84908. * @param label is the label for the selector
  84909. * @param func is the function called when the Selector is checked
  84910. * @param checked is true when Selector is checked
  84911. */
  84912. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  84913. /** For a given group position of correct type add a radio button
  84914. * @param groupNb is the number of the group to remove the selector from
  84915. * @param label is the label for the selector
  84916. * @param func is the function called when the Selector is checked
  84917. * @param checked is true when Selector is checked
  84918. */
  84919. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  84920. /**
  84921. * For a given slider group add a slider
  84922. * @param groupNb is the number of the group to add the slider to
  84923. * @param label is the label for the Slider
  84924. * @param func is the function called when the Slider moves
  84925. * @param unit is a string describing the units used, eg degrees or metres
  84926. * @param min is the minimum value for the Slider
  84927. * @param max is the maximum value for the Slider
  84928. * @param value is the start value for the Slider between min and max
  84929. * @param onVal is the function used to format the value displayed, eg radians to degrees
  84930. */
  84931. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  84932. }
  84933. }
  84934. declare module BABYLON.GUI {
  84935. /**
  84936. * Class used to hold a the container for ScrollViewer
  84937. * @hidden
  84938. */
  84939. export class _ScrollViewerWindow extends Container {
  84940. parentClientWidth: number;
  84941. parentClientHeight: number;
  84942. private _freezeControls;
  84943. private _parentMeasure;
  84944. private _oldLeft;
  84945. private _oldTop;
  84946. get freezeControls(): boolean;
  84947. set freezeControls(value: boolean);
  84948. private _bucketWidth;
  84949. private _bucketHeight;
  84950. private _buckets;
  84951. private _bucketLen;
  84952. get bucketWidth(): number;
  84953. get bucketHeight(): number;
  84954. setBucketSizes(width: number, height: number): void;
  84955. private _useBuckets;
  84956. private _makeBuckets;
  84957. private _dispatchInBuckets;
  84958. private _updateMeasures;
  84959. private _updateChildrenMeasures;
  84960. private _restoreMeasures;
  84961. /**
  84962. * Creates a new ScrollViewerWindow
  84963. * @param name of ScrollViewerWindow
  84964. */
  84965. constructor(name?: string);
  84966. protected _getTypeName(): string;
  84967. /** @hidden */
  84968. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84969. /** @hidden */
  84970. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  84971. private _scrollChildren;
  84972. private _scrollChildrenWithBuckets;
  84973. /** @hidden */
  84974. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  84975. protected _postMeasure(): void;
  84976. }
  84977. }
  84978. declare module BABYLON.GUI {
  84979. /**
  84980. * Class used to create slider controls
  84981. */
  84982. export class ScrollBar extends BaseSlider {
  84983. name?: string | undefined;
  84984. private _background;
  84985. private _borderColor;
  84986. private _tempMeasure;
  84987. /** Gets or sets border color */
  84988. get borderColor(): string;
  84989. set borderColor(value: string);
  84990. /** Gets or sets background color */
  84991. get background(): string;
  84992. set background(value: string);
  84993. /**
  84994. * Creates a new Slider
  84995. * @param name defines the control name
  84996. */
  84997. constructor(name?: string | undefined);
  84998. protected _getTypeName(): string;
  84999. protected _getThumbThickness(): number;
  85000. _draw(context: CanvasRenderingContext2D): void;
  85001. private _first;
  85002. private _originX;
  85003. private _originY;
  85004. /** @hidden */
  85005. protected _updateValueFromPointer(x: number, y: number): void;
  85006. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85007. }
  85008. }
  85009. declare module BABYLON.GUI {
  85010. /**
  85011. * Class used to create slider controls
  85012. */
  85013. export class ImageScrollBar extends BaseSlider {
  85014. name?: string | undefined;
  85015. private _backgroundBaseImage;
  85016. private _backgroundImage;
  85017. private _thumbImage;
  85018. private _thumbBaseImage;
  85019. private _thumbLength;
  85020. private _thumbHeight;
  85021. private _barImageHeight;
  85022. private _tempMeasure;
  85023. /** Number of 90° rotation to apply on the images when in vertical mode */
  85024. num90RotationInVerticalMode: number;
  85025. /**
  85026. * Gets or sets the image used to render the background for horizontal bar
  85027. */
  85028. get backgroundImage(): Image;
  85029. set backgroundImage(value: Image);
  85030. /**
  85031. * Gets or sets the image used to render the thumb
  85032. */
  85033. get thumbImage(): Image;
  85034. set thumbImage(value: Image);
  85035. /**
  85036. * Gets or sets the length of the thumb
  85037. */
  85038. get thumbLength(): number;
  85039. set thumbLength(value: number);
  85040. /**
  85041. * Gets or sets the height of the thumb
  85042. */
  85043. get thumbHeight(): number;
  85044. set thumbHeight(value: number);
  85045. /**
  85046. * Gets or sets the height of the bar image
  85047. */
  85048. get barImageHeight(): number;
  85049. set barImageHeight(value: number);
  85050. /**
  85051. * Creates a new ImageScrollBar
  85052. * @param name defines the control name
  85053. */
  85054. constructor(name?: string | undefined);
  85055. protected _getTypeName(): string;
  85056. protected _getThumbThickness(): number;
  85057. _draw(context: CanvasRenderingContext2D): void;
  85058. private _first;
  85059. private _originX;
  85060. private _originY;
  85061. /** @hidden */
  85062. protected _updateValueFromPointer(x: number, y: number): void;
  85063. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85064. }
  85065. }
  85066. declare module BABYLON.GUI {
  85067. /**
  85068. * Class used to hold a viewer window and sliders in a grid
  85069. */
  85070. export class ScrollViewer extends Rectangle {
  85071. private _grid;
  85072. private _horizontalBarSpace;
  85073. private _verticalBarSpace;
  85074. private _dragSpace;
  85075. private _horizontalBar;
  85076. private _verticalBar;
  85077. private _barColor;
  85078. private _barBackground;
  85079. private _barImage;
  85080. private _horizontalBarImage;
  85081. private _verticalBarImage;
  85082. private _barBackgroundImage;
  85083. private _horizontalBarBackgroundImage;
  85084. private _verticalBarBackgroundImage;
  85085. private _barSize;
  85086. private _window;
  85087. private _pointerIsOver;
  85088. private _wheelPrecision;
  85089. private _onWheelObserver;
  85090. private _clientWidth;
  85091. private _clientHeight;
  85092. private _useImageBar;
  85093. private _thumbLength;
  85094. private _thumbHeight;
  85095. private _barImageHeight;
  85096. private _horizontalBarImageHeight;
  85097. private _verticalBarImageHeight;
  85098. private _oldWindowContentsWidth;
  85099. private _oldWindowContentsHeight;
  85100. /**
  85101. * Gets the horizontal scrollbar
  85102. */
  85103. get horizontalBar(): ScrollBar | ImageScrollBar;
  85104. /**
  85105. * Gets the vertical scrollbar
  85106. */
  85107. get verticalBar(): ScrollBar | ImageScrollBar;
  85108. /**
  85109. * Adds a new control to the current container
  85110. * @param control defines the control to add
  85111. * @returns the current container
  85112. */
  85113. addControl(control: BABYLON.Nullable<Control>): Container;
  85114. /**
  85115. * Removes a control from the current container
  85116. * @param control defines the control to remove
  85117. * @returns the current container
  85118. */
  85119. removeControl(control: Control): Container;
  85120. /** Gets the list of children */
  85121. get children(): Control[];
  85122. _flagDescendantsAsMatrixDirty(): void;
  85123. /**
  85124. * Freezes or unfreezes the controls in the window.
  85125. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  85126. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  85127. */
  85128. get freezeControls(): boolean;
  85129. set freezeControls(value: boolean);
  85130. /** Gets the bucket width */
  85131. get bucketWidth(): number;
  85132. /** Gets the bucket height */
  85133. get bucketHeight(): number;
  85134. /**
  85135. * Sets the bucket sizes.
  85136. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  85137. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  85138. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  85139. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  85140. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  85141. * used), that's why it is not enabled by default.
  85142. * @param width width of the bucket
  85143. * @param height height of the bucket
  85144. */
  85145. setBucketSizes(width: number, height: number): void;
  85146. private _forceHorizontalBar;
  85147. private _forceVerticalBar;
  85148. /**
  85149. * Forces the horizontal scroll bar to be displayed
  85150. */
  85151. get forceHorizontalBar(): boolean;
  85152. set forceHorizontalBar(value: boolean);
  85153. /**
  85154. * Forces the vertical scroll bar to be displayed
  85155. */
  85156. get forceVerticalBar(): boolean;
  85157. set forceVerticalBar(value: boolean);
  85158. /**
  85159. * Creates a new ScrollViewer
  85160. * @param name of ScrollViewer
  85161. */
  85162. constructor(name?: string, isImageBased?: boolean);
  85163. /** Reset the scroll viewer window to initial size */
  85164. resetWindow(): void;
  85165. protected _getTypeName(): string;
  85166. private _buildClientSizes;
  85167. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85168. protected _postMeasure(): void;
  85169. /**
  85170. * Gets or sets the mouse wheel precision
  85171. * from 0 to 1 with a default value of 0.05
  85172. * */
  85173. get wheelPrecision(): number;
  85174. set wheelPrecision(value: number);
  85175. /** Gets or sets the scroll bar container background color */
  85176. get scrollBackground(): string;
  85177. set scrollBackground(color: string);
  85178. /** Gets or sets the bar color */
  85179. get barColor(): string;
  85180. set barColor(color: string);
  85181. /** Gets or sets the bar image */
  85182. get thumbImage(): Image;
  85183. set thumbImage(value: Image);
  85184. /** Gets or sets the horizontal bar image */
  85185. get horizontalThumbImage(): Image;
  85186. set horizontalThumbImage(value: Image);
  85187. /** Gets or sets the vertical bar image */
  85188. get verticalThumbImage(): Image;
  85189. set verticalThumbImage(value: Image);
  85190. /** Gets or sets the size of the bar */
  85191. get barSize(): number;
  85192. set barSize(value: number);
  85193. /** Gets or sets the length of the thumb */
  85194. get thumbLength(): number;
  85195. set thumbLength(value: number);
  85196. /** Gets or sets the height of the thumb */
  85197. get thumbHeight(): number;
  85198. set thumbHeight(value: number);
  85199. /** Gets or sets the height of the bar image */
  85200. get barImageHeight(): number;
  85201. set barImageHeight(value: number);
  85202. /** Gets or sets the height of the horizontal bar image */
  85203. get horizontalBarImageHeight(): number;
  85204. set horizontalBarImageHeight(value: number);
  85205. /** Gets or sets the height of the vertical bar image */
  85206. get verticalBarImageHeight(): number;
  85207. set verticalBarImageHeight(value: number);
  85208. /** Gets or sets the bar background */
  85209. get barBackground(): string;
  85210. set barBackground(color: string);
  85211. /** Gets or sets the bar background image */
  85212. get barImage(): Image;
  85213. set barImage(value: Image);
  85214. /** Gets or sets the horizontal bar background image */
  85215. get horizontalBarImage(): Image;
  85216. set horizontalBarImage(value: Image);
  85217. /** Gets or sets the vertical bar background image */
  85218. get verticalBarImage(): Image;
  85219. set verticalBarImage(value: Image);
  85220. private _setWindowPosition;
  85221. /** @hidden */
  85222. private _updateScroller;
  85223. _link(host: AdvancedDynamicTexture): void;
  85224. /** @hidden */
  85225. private _addBar;
  85226. /** @hidden */
  85227. private _attachWheel;
  85228. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85229. /** Releases associated resources */
  85230. dispose(): void;
  85231. }
  85232. }
  85233. declare module BABYLON.GUI {
  85234. /**
  85235. * Class used to create toggle buttons
  85236. */
  85237. export class ToggleButton extends Rectangle {
  85238. name?: string | undefined;
  85239. /**
  85240. * Function called to generate the toActive animation
  85241. */
  85242. toActiveAnimation: () => void;
  85243. /**
  85244. * Function called to generate the toInactive animation
  85245. */
  85246. toInactiveAnimation: () => void;
  85247. /**
  85248. * Function called to generate a pointer enter animation when the toggle button is active.
  85249. */
  85250. pointerEnterActiveAnimation: () => void;
  85251. /**
  85252. * Function called to generate a pointer out animation when the toggle button is active.
  85253. */
  85254. pointerOutActiveAnimation: () => void;
  85255. /**
  85256. * Function called to generate a pointer down animation when the toggle button is active.
  85257. */
  85258. pointerDownActiveAnimation: () => void;
  85259. /**
  85260. * Function called to generate a pointer up animation when the toggle button is active.
  85261. */
  85262. pointerUpActiveAnimation: () => void;
  85263. /**
  85264. * Function called to generate a pointer enter animation when the toggle button is inactive.
  85265. */
  85266. pointerEnterInactiveAnimation: () => void;
  85267. /**
  85268. * Function called to generate a pointer out animation when the toggle button is inactive.
  85269. */
  85270. pointerOutInactiveAnimation: () => void;
  85271. /**
  85272. * Function called to generate a pointer down animation when the toggle button is inactive.
  85273. */
  85274. pointerDownInactiveAnimation: () => void;
  85275. /**
  85276. * Function called to generate a pointer up animation when the toggle button is inactive.
  85277. */
  85278. pointerUpInactiveAnimation: () => void;
  85279. /** BABYLON.Observable raised when isActive is changed */
  85280. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  85281. /**
  85282. * 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
  85283. */
  85284. delegatePickingToChildren: boolean;
  85285. private _image;
  85286. /**
  85287. * Returns the ToggleButton's image control if it exists
  85288. */
  85289. get image(): BABYLON.Nullable<Image>;
  85290. private _textBlock;
  85291. /**
  85292. * Returns the ToggleButton's child TextBlock control if it exists
  85293. */
  85294. get textBlock(): BABYLON.Nullable<TextBlock>;
  85295. private _group;
  85296. /** Gets or sets group name this toggle button belongs to */
  85297. get group(): string;
  85298. set group(value: string);
  85299. private _isActive;
  85300. /** Gets or sets a boolean indicating if the toogle button is active or not */
  85301. get isActive(): boolean;
  85302. set isActive(value: boolean);
  85303. /**
  85304. * Creates a new ToggleButton
  85305. * @param name defines the control name
  85306. * @param group defines the toggle group this toggle belongs to
  85307. */
  85308. constructor(name?: string | undefined, group?: string);
  85309. protected _getTypeName(): string;
  85310. /** @hidden */
  85311. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  85312. /** @hidden */
  85313. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  85314. /** @hidden */
  85315. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  85316. /** @hidden */
  85317. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85318. /** @hidden */
  85319. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  85320. }
  85321. }
  85322. declare module BABYLON.GUI {
  85323. /** Class used to render a grid */
  85324. export class DisplayGrid extends Control {
  85325. name?: string | undefined;
  85326. private _cellWidth;
  85327. private _cellHeight;
  85328. private _minorLineTickness;
  85329. private _minorLineColor;
  85330. private _majorLineTickness;
  85331. private _majorLineColor;
  85332. private _majorLineFrequency;
  85333. private _background;
  85334. private _displayMajorLines;
  85335. private _displayMinorLines;
  85336. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  85337. get displayMinorLines(): boolean;
  85338. set displayMinorLines(value: boolean);
  85339. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  85340. get displayMajorLines(): boolean;
  85341. set displayMajorLines(value: boolean);
  85342. /** Gets or sets background color (Black by default) */
  85343. get background(): string;
  85344. set background(value: string);
  85345. /** Gets or sets the width of each cell (20 by default) */
  85346. get cellWidth(): number;
  85347. set cellWidth(value: number);
  85348. /** Gets or sets the height of each cell (20 by default) */
  85349. get cellHeight(): number;
  85350. set cellHeight(value: number);
  85351. /** Gets or sets the tickness of minor lines (1 by default) */
  85352. get minorLineTickness(): number;
  85353. set minorLineTickness(value: number);
  85354. /** Gets or sets the color of minor lines (DarkGray by default) */
  85355. get minorLineColor(): string;
  85356. set minorLineColor(value: string);
  85357. /** Gets or sets the tickness of major lines (2 by default) */
  85358. get majorLineTickness(): number;
  85359. set majorLineTickness(value: number);
  85360. /** Gets or sets the color of major lines (White by default) */
  85361. get majorLineColor(): string;
  85362. set majorLineColor(value: string);
  85363. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  85364. get majorLineFrequency(): number;
  85365. set majorLineFrequency(value: number);
  85366. /**
  85367. * Creates a new GridDisplayRectangle
  85368. * @param name defines the control name
  85369. */
  85370. constructor(name?: string | undefined);
  85371. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85372. protected _getTypeName(): string;
  85373. }
  85374. }
  85375. declare module BABYLON.GUI {
  85376. /**
  85377. * Class used to create slider controls based on images
  85378. */
  85379. export class ImageBasedSlider extends BaseSlider {
  85380. name?: string | undefined;
  85381. private _backgroundImage;
  85382. private _thumbImage;
  85383. private _valueBarImage;
  85384. private _tempMeasure;
  85385. get displayThumb(): boolean;
  85386. set displayThumb(value: boolean);
  85387. /**
  85388. * Gets or sets the image used to render the background
  85389. */
  85390. get backgroundImage(): Image;
  85391. set backgroundImage(value: Image);
  85392. /**
  85393. * Gets or sets the image used to render the value bar
  85394. */
  85395. get valueBarImage(): Image;
  85396. set valueBarImage(value: Image);
  85397. /**
  85398. * Gets or sets the image used to render the thumb
  85399. */
  85400. get thumbImage(): Image;
  85401. set thumbImage(value: Image);
  85402. /**
  85403. * Creates a new ImageBasedSlider
  85404. * @param name defines the control name
  85405. */
  85406. constructor(name?: string | undefined);
  85407. protected _getTypeName(): string;
  85408. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85409. }
  85410. }
  85411. declare module BABYLON.GUI {
  85412. /**
  85413. * Forcing an export so that this code will execute
  85414. * @hidden
  85415. */
  85416. const name = "Statics";
  85417. }
  85418. declare module BABYLON.GUI {
  85419. /**
  85420. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  85421. */
  85422. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  85423. /**
  85424. * Define the instrumented AdvancedDynamicTexture.
  85425. */
  85426. texture: AdvancedDynamicTexture;
  85427. private _captureRenderTime;
  85428. private _renderTime;
  85429. private _captureLayoutTime;
  85430. private _layoutTime;
  85431. private _onBeginRenderObserver;
  85432. private _onEndRenderObserver;
  85433. private _onBeginLayoutObserver;
  85434. private _onEndLayoutObserver;
  85435. /**
  85436. * Gets the perf counter used to capture render time
  85437. */
  85438. get renderTimeCounter(): BABYLON.PerfCounter;
  85439. /**
  85440. * Gets the perf counter used to capture layout time
  85441. */
  85442. get layoutTimeCounter(): BABYLON.PerfCounter;
  85443. /**
  85444. * Enable or disable the render time capture
  85445. */
  85446. get captureRenderTime(): boolean;
  85447. set captureRenderTime(value: boolean);
  85448. /**
  85449. * Enable or disable the layout time capture
  85450. */
  85451. get captureLayoutTime(): boolean;
  85452. set captureLayoutTime(value: boolean);
  85453. /**
  85454. * Instantiates a new advanced dynamic texture instrumentation.
  85455. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  85456. * @param texture Defines the AdvancedDynamicTexture to instrument
  85457. */
  85458. constructor(
  85459. /**
  85460. * Define the instrumented AdvancedDynamicTexture.
  85461. */
  85462. texture: AdvancedDynamicTexture);
  85463. /**
  85464. * Dispose and release associated resources.
  85465. */
  85466. dispose(): void;
  85467. }
  85468. }
  85469. declare module BABYLON.GUI {
  85470. /**
  85471. * Class used to load GUI via XML.
  85472. */
  85473. export class XmlLoader {
  85474. private _nodes;
  85475. private _nodeTypes;
  85476. private _isLoaded;
  85477. private _objectAttributes;
  85478. private _parentClass;
  85479. /**
  85480. * Create a new xml loader
  85481. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  85482. */
  85483. constructor(parentClass?: null);
  85484. private _getChainElement;
  85485. private _getClassAttribute;
  85486. private _createGuiElement;
  85487. private _parseGrid;
  85488. private _parseElement;
  85489. private _prepareSourceElement;
  85490. private _parseElementsFromSource;
  85491. private _parseXml;
  85492. /**
  85493. * Gets if the loading has finished.
  85494. * @returns whether the loading has finished or not
  85495. */
  85496. isLoaded(): boolean;
  85497. /**
  85498. * Gets a loaded node / control by id.
  85499. * @param id the Controls id set in the xml
  85500. * @returns element of type Control
  85501. */
  85502. getNodeById(id: string): any;
  85503. /**
  85504. * Gets all loaded nodes / controls
  85505. * @returns Array of controls
  85506. */
  85507. getNodes(): any;
  85508. /**
  85509. * Initiates the xml layout loading
  85510. * @param xmlFile defines the xml layout to load
  85511. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  85512. * @param callback defines the callback called on layout load.
  85513. */
  85514. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  85515. }
  85516. }
  85517. declare module BABYLON.GUI {
  85518. /**
  85519. * Class used to create containers for controls
  85520. */
  85521. export class Container3D extends Control3D {
  85522. private _blockLayout;
  85523. /**
  85524. * Gets the list of child controls
  85525. */
  85526. protected _children: Control3D[];
  85527. /**
  85528. * Gets the list of child controls
  85529. */
  85530. get children(): Array<Control3D>;
  85531. /**
  85532. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  85533. * This is helpful to optimize layout operation when adding multiple children in a row
  85534. */
  85535. get blockLayout(): boolean;
  85536. set blockLayout(value: boolean);
  85537. /**
  85538. * Creates a new container
  85539. * @param name defines the container name
  85540. */
  85541. constructor(name?: string);
  85542. /**
  85543. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  85544. * @returns the current container
  85545. */
  85546. updateLayout(): Container3D;
  85547. /**
  85548. * Gets a boolean indicating if the given control is in the children of this control
  85549. * @param control defines the control to check
  85550. * @returns true if the control is in the child list
  85551. */
  85552. containsControl(control: Control3D): boolean;
  85553. /**
  85554. * Adds a control to the children of this control
  85555. * @param control defines the control to add
  85556. * @returns the current container
  85557. */
  85558. addControl(control: Control3D): Container3D;
  85559. /**
  85560. * This function will be called everytime a new control is added
  85561. */
  85562. protected _arrangeChildren(): void;
  85563. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  85564. /**
  85565. * Removes a control from the children of this control
  85566. * @param control defines the control to remove
  85567. * @returns the current container
  85568. */
  85569. removeControl(control: Control3D): Container3D;
  85570. protected _getTypeName(): string;
  85571. /**
  85572. * Releases all associated resources
  85573. */
  85574. dispose(): void;
  85575. /** Control rotation will remain unchanged */
  85576. static readonly UNSET_ORIENTATION: number;
  85577. /** Control will rotate to make it look at sphere central axis */
  85578. static readonly FACEORIGIN_ORIENTATION: number;
  85579. /** Control will rotate to make it look back at sphere central axis */
  85580. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  85581. /** Control will rotate to look at z axis (0, 0, 1) */
  85582. static readonly FACEFORWARD_ORIENTATION: number;
  85583. /** Control will rotate to look at negative z axis (0, 0, -1) */
  85584. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  85585. }
  85586. }
  85587. declare module BABYLON.GUI {
  85588. /**
  85589. * Class used to manage 3D user interface
  85590. * @see https://doc.babylonjs.com/how_to/gui3d
  85591. */
  85592. export class GUI3DManager implements BABYLON.IDisposable {
  85593. private _scene;
  85594. private _sceneDisposeObserver;
  85595. private _utilityLayer;
  85596. private _rootContainer;
  85597. private _pointerObserver;
  85598. private _pointerOutObserver;
  85599. /** @hidden */
  85600. _lastPickedControl: Control3D;
  85601. /** @hidden */
  85602. _lastControlOver: {
  85603. [pointerId: number]: Control3D;
  85604. };
  85605. /** @hidden */
  85606. _lastControlDown: {
  85607. [pointerId: number]: Control3D;
  85608. };
  85609. /**
  85610. * BABYLON.Observable raised when the point picked by the pointer events changed
  85611. */
  85612. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  85613. /** @hidden */
  85614. _sharedMaterials: {
  85615. [key: string]: BABYLON.Material;
  85616. };
  85617. /** Gets the hosting scene */
  85618. get scene(): BABYLON.Scene;
  85619. /** Gets associated utility layer */
  85620. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  85621. /**
  85622. * Creates a new GUI3DManager
  85623. * @param scene
  85624. */
  85625. constructor(scene?: BABYLON.Scene);
  85626. private _handlePointerOut;
  85627. private _doPicking;
  85628. /**
  85629. * Gets the root container
  85630. */
  85631. get rootContainer(): Container3D;
  85632. /**
  85633. * Gets a boolean indicating if the given control is in the root child list
  85634. * @param control defines the control to check
  85635. * @returns true if the control is in the root child list
  85636. */
  85637. containsControl(control: Control3D): boolean;
  85638. /**
  85639. * Adds a control to the root child list
  85640. * @param control defines the control to add
  85641. * @returns the current manager
  85642. */
  85643. addControl(control: Control3D): GUI3DManager;
  85644. /**
  85645. * Removes a control from the root child list
  85646. * @param control defines the control to remove
  85647. * @returns the current container
  85648. */
  85649. removeControl(control: Control3D): GUI3DManager;
  85650. /**
  85651. * Releases all associated resources
  85652. */
  85653. dispose(): void;
  85654. }
  85655. }
  85656. declare module BABYLON.GUI {
  85657. /**
  85658. * Class used to transport BABYLON.Vector3 information for pointer events
  85659. */
  85660. export class Vector3WithInfo extends BABYLON.Vector3 {
  85661. /** defines the current mouse button index */
  85662. buttonIndex: number;
  85663. /**
  85664. * Creates a new Vector3WithInfo
  85665. * @param source defines the vector3 data to transport
  85666. * @param buttonIndex defines the current mouse button index
  85667. */
  85668. constructor(source: BABYLON.Vector3,
  85669. /** defines the current mouse button index */
  85670. buttonIndex?: number);
  85671. }
  85672. }
  85673. declare module BABYLON.GUI {
  85674. /**
  85675. * Class used as base class for controls
  85676. */
  85677. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  85678. /** Defines the control name */
  85679. name?: string | undefined;
  85680. /** @hidden */
  85681. _host: GUI3DManager;
  85682. private _node;
  85683. private _downCount;
  85684. private _enterCount;
  85685. private _downPointerIds;
  85686. private _isVisible;
  85687. /** Gets or sets the control position in world space */
  85688. get position(): BABYLON.Vector3;
  85689. set position(value: BABYLON.Vector3);
  85690. /** Gets or sets the control scaling in world space */
  85691. get scaling(): BABYLON.Vector3;
  85692. set scaling(value: BABYLON.Vector3);
  85693. /** Callback used to start pointer enter animation */
  85694. pointerEnterAnimation: () => void;
  85695. /** Callback used to start pointer out animation */
  85696. pointerOutAnimation: () => void;
  85697. /** Callback used to start pointer down animation */
  85698. pointerDownAnimation: () => void;
  85699. /** Callback used to start pointer up animation */
  85700. pointerUpAnimation: () => void;
  85701. /**
  85702. * An event triggered when the pointer move over the control
  85703. */
  85704. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  85705. /**
  85706. * An event triggered when the pointer move out of the control
  85707. */
  85708. onPointerOutObservable: BABYLON.Observable<Control3D>;
  85709. /**
  85710. * An event triggered when the pointer taps the control
  85711. */
  85712. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  85713. /**
  85714. * An event triggered when pointer is up
  85715. */
  85716. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  85717. /**
  85718. * An event triggered when a control is clicked on (with a mouse)
  85719. */
  85720. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  85721. /**
  85722. * An event triggered when pointer enters the control
  85723. */
  85724. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  85725. /**
  85726. * Gets or sets the parent container
  85727. */
  85728. parent: BABYLON.Nullable<Container3D>;
  85729. private _behaviors;
  85730. /**
  85731. * Gets the list of attached behaviors
  85732. * @see https://doc.babylonjs.com/features/behaviour
  85733. */
  85734. get behaviors(): BABYLON.Behavior<Control3D>[];
  85735. /**
  85736. * Attach a behavior to the control
  85737. * @see https://doc.babylonjs.com/features/behaviour
  85738. * @param behavior defines the behavior to attach
  85739. * @returns the current control
  85740. */
  85741. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  85742. /**
  85743. * Remove an attached behavior
  85744. * @see https://doc.babylonjs.com/features/behaviour
  85745. * @param behavior defines the behavior to attach
  85746. * @returns the current control
  85747. */
  85748. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  85749. /**
  85750. * Gets an attached behavior by name
  85751. * @param name defines the name of the behavior to look for
  85752. * @see https://doc.babylonjs.com/features/behaviour
  85753. * @returns null if behavior was not found else the requested behavior
  85754. */
  85755. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  85756. /** Gets or sets a boolean indicating if the control is visible */
  85757. get isVisible(): boolean;
  85758. set isVisible(value: boolean);
  85759. /**
  85760. * Creates a new control
  85761. * @param name defines the control name
  85762. */
  85763. constructor(
  85764. /** Defines the control name */
  85765. name?: string | undefined);
  85766. /**
  85767. * Gets a string representing the class name
  85768. */
  85769. get typeName(): string;
  85770. /**
  85771. * Get the current class name of the control.
  85772. * @returns current class name
  85773. */
  85774. getClassName(): string;
  85775. protected _getTypeName(): string;
  85776. /**
  85777. * Gets the transform node used by this control
  85778. */
  85779. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  85780. /**
  85781. * Gets the mesh used to render this control
  85782. */
  85783. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  85784. /**
  85785. * Link the control as child of the given node
  85786. * @param node defines the node to link to. Use null to unlink the control
  85787. * @returns the current control
  85788. */
  85789. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  85790. /** @hidden **/
  85791. _prepareNode(scene: BABYLON.Scene): void;
  85792. /**
  85793. * Node creation.
  85794. * Can be overriden by children
  85795. * @param scene defines the scene where the node must be attached
  85796. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  85797. */
  85798. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  85799. /**
  85800. * Affect a material to the given mesh
  85801. * @param mesh defines the mesh which will represent the control
  85802. */
  85803. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  85804. /** @hidden */
  85805. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  85806. /** @hidden */
  85807. _onPointerEnter(target: Control3D): boolean;
  85808. /** @hidden */
  85809. _onPointerOut(target: Control3D): void;
  85810. /** @hidden */
  85811. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  85812. /** @hidden */
  85813. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85814. /** @hidden */
  85815. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  85816. /** @hidden */
  85817. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  85818. /** @hidden */
  85819. _disposeNode(): void;
  85820. /**
  85821. * Releases all associated resources
  85822. */
  85823. dispose(): void;
  85824. }
  85825. }
  85826. declare module BABYLON.GUI {
  85827. /**
  85828. * Class used as a root to all buttons
  85829. */
  85830. export class AbstractButton3D extends Control3D {
  85831. /**
  85832. * Creates a new button
  85833. * @param name defines the control name
  85834. */
  85835. constructor(name?: string);
  85836. protected _getTypeName(): string;
  85837. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  85838. }
  85839. }
  85840. declare module BABYLON.GUI {
  85841. /**
  85842. * Class used to create a button in 3D
  85843. */
  85844. export class Button3D extends AbstractButton3D {
  85845. /** @hidden */
  85846. protected _currentMaterial: BABYLON.Material;
  85847. private _facadeTexture;
  85848. private _content;
  85849. private _contentResolution;
  85850. private _contentScaleRatio;
  85851. /**
  85852. * Gets or sets the texture resolution used to render content (512 by default)
  85853. */
  85854. get contentResolution(): BABYLON.int;
  85855. set contentResolution(value: BABYLON.int);
  85856. /**
  85857. * Gets or sets the texture scale ratio used to render content (2 by default)
  85858. */
  85859. get contentScaleRatio(): number;
  85860. set contentScaleRatio(value: number);
  85861. protected _disposeFacadeTexture(): void;
  85862. protected _resetContent(): void;
  85863. /**
  85864. * Creates a new button
  85865. * @param name defines the control name
  85866. */
  85867. constructor(name?: string);
  85868. /**
  85869. * Gets or sets the GUI 2D content used to display the button's facade
  85870. */
  85871. get content(): Control;
  85872. set content(value: Control);
  85873. /**
  85874. * Apply the facade texture (created from the content property).
  85875. * This function can be overloaded by child classes
  85876. * @param facadeTexture defines the AdvancedDynamicTexture to use
  85877. */
  85878. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  85879. protected _getTypeName(): string;
  85880. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  85881. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  85882. /**
  85883. * Releases all associated resources
  85884. */
  85885. dispose(): void;
  85886. }
  85887. }
  85888. declare module BABYLON.GUI {
  85889. /**
  85890. * Abstract class used to create a container panel deployed on the surface of a volume
  85891. */
  85892. export abstract class VolumeBasedPanel extends Container3D {
  85893. private _columns;
  85894. private _rows;
  85895. private _rowThenColum;
  85896. private _orientation;
  85897. protected _cellWidth: number;
  85898. protected _cellHeight: number;
  85899. /**
  85900. * Gets or sets the distance between elements
  85901. */
  85902. margin: number;
  85903. /**
  85904. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  85905. * | Value | Type | Description |
  85906. * | ----- | ----------------------------------- | ----------- |
  85907. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  85908. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  85909. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  85910. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  85911. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  85912. */
  85913. get orientation(): number;
  85914. set orientation(value: number);
  85915. /**
  85916. * Gets or sets the number of columns requested (10 by default).
  85917. * The panel will automatically compute the number of rows based on number of child controls.
  85918. */
  85919. get columns(): BABYLON.int;
  85920. set columns(value: BABYLON.int);
  85921. /**
  85922. * Gets or sets a the number of rows requested.
  85923. * The panel will automatically compute the number of columns based on number of child controls.
  85924. */
  85925. get rows(): BABYLON.int;
  85926. set rows(value: BABYLON.int);
  85927. /**
  85928. * Creates new VolumeBasedPanel
  85929. */
  85930. constructor();
  85931. protected _arrangeChildren(): void;
  85932. /** Child classes must implement this function to provide correct control positioning */
  85933. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  85934. /** Child classes can implement this function to provide additional processing */
  85935. protected _finalProcessing(): void;
  85936. }
  85937. }
  85938. declare module BABYLON.GUI {
  85939. /**
  85940. * Class used to create a container panel deployed on the surface of a cylinder
  85941. */
  85942. export class CylinderPanel extends VolumeBasedPanel {
  85943. private _radius;
  85944. /**
  85945. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  85946. */
  85947. get radius(): BABYLON.float;
  85948. set radius(value: BABYLON.float);
  85949. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  85950. private _cylindricalMapping;
  85951. }
  85952. }
  85953. declare module BABYLON.GUI {
  85954. /** @hidden */
  85955. export var fluentVertexShader: {
  85956. name: string;
  85957. shader: string;
  85958. };
  85959. }
  85960. declare module BABYLON.GUI {
  85961. /** @hidden */
  85962. export var fluentPixelShader: {
  85963. name: string;
  85964. shader: string;
  85965. };
  85966. }
  85967. declare module BABYLON.GUI {
  85968. /** @hidden */
  85969. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  85970. INNERGLOW: boolean;
  85971. BORDER: boolean;
  85972. HOVERLIGHT: boolean;
  85973. TEXTURE: boolean;
  85974. constructor();
  85975. }
  85976. /**
  85977. * Class used to render controls with fluent desgin
  85978. */
  85979. export class FluentMaterial extends BABYLON.PushMaterial {
  85980. /**
  85981. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  85982. */
  85983. innerGlowColorIntensity: number;
  85984. /**
  85985. * Gets or sets the inner glow color (white by default)
  85986. */
  85987. innerGlowColor: BABYLON.Color3;
  85988. /**
  85989. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  85990. */
  85991. albedoColor: BABYLON.Color3;
  85992. /**
  85993. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  85994. */
  85995. renderBorders: boolean;
  85996. /**
  85997. * Gets or sets border width (default is 0.5)
  85998. */
  85999. borderWidth: number;
  86000. /**
  86001. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  86002. */
  86003. edgeSmoothingValue: number;
  86004. /**
  86005. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  86006. */
  86007. borderMinValue: number;
  86008. /**
  86009. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  86010. */
  86011. renderHoverLight: boolean;
  86012. /**
  86013. * Gets or sets the radius used to render the hover light (default is 1.0)
  86014. */
  86015. hoverRadius: number;
  86016. /**
  86017. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  86018. */
  86019. hoverColor: BABYLON.Color4;
  86020. /**
  86021. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  86022. */
  86023. hoverPosition: BABYLON.Vector3;
  86024. private _albedoTexture;
  86025. /** Gets or sets the texture to use for albedo color */
  86026. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86027. /**
  86028. * Creates a new Fluent material
  86029. * @param name defines the name of the material
  86030. * @param scene defines the hosting scene
  86031. */
  86032. constructor(name: string, scene: BABYLON.Scene);
  86033. needAlphaBlending(): boolean;
  86034. needAlphaTesting(): boolean;
  86035. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86036. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86037. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86038. getActiveTextures(): BABYLON.BaseTexture[];
  86039. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86040. dispose(forceDisposeEffect?: boolean): void;
  86041. clone(name: string): FluentMaterial;
  86042. serialize(): any;
  86043. getClassName(): string;
  86044. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  86045. }
  86046. }
  86047. declare module BABYLON.GUI {
  86048. /**
  86049. * Class used to create a holographic button in 3D
  86050. */
  86051. export class HolographicButton extends Button3D {
  86052. private _backPlate;
  86053. private _textPlate;
  86054. private _frontPlate;
  86055. private _text;
  86056. private _imageUrl;
  86057. private _shareMaterials;
  86058. private _frontMaterial;
  86059. private _backMaterial;
  86060. private _plateMaterial;
  86061. private _pickedPointObserver;
  86062. private _tooltipFade;
  86063. private _tooltipTextBlock;
  86064. private _tooltipTexture;
  86065. private _tooltipMesh;
  86066. private _tooltipHoverObserver;
  86067. private _tooltipOutObserver;
  86068. private _disposeTooltip;
  86069. /**
  86070. * Rendering ground id of all the mesh in the button
  86071. */
  86072. set renderingGroupId(id: number);
  86073. get renderingGroupId(): number;
  86074. /**
  86075. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  86076. */
  86077. set tooltipText(text: BABYLON.Nullable<string>);
  86078. get tooltipText(): BABYLON.Nullable<string>;
  86079. /**
  86080. * Gets or sets text for the button
  86081. */
  86082. get text(): string;
  86083. set text(value: string);
  86084. /**
  86085. * Gets or sets the image url for the button
  86086. */
  86087. get imageUrl(): string;
  86088. set imageUrl(value: string);
  86089. /**
  86090. * Gets the back material used by this button
  86091. */
  86092. get backMaterial(): FluentMaterial;
  86093. /**
  86094. * Gets the front material used by this button
  86095. */
  86096. get frontMaterial(): FluentMaterial;
  86097. /**
  86098. * Gets the plate material used by this button
  86099. */
  86100. get plateMaterial(): BABYLON.StandardMaterial;
  86101. /**
  86102. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  86103. */
  86104. get shareMaterials(): boolean;
  86105. /**
  86106. * Creates a new button
  86107. * @param name defines the control name
  86108. */
  86109. constructor(name?: string, shareMaterials?: boolean);
  86110. protected _getTypeName(): string;
  86111. private _rebuildContent;
  86112. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86113. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86114. private _createBackMaterial;
  86115. private _createFrontMaterial;
  86116. private _createPlateMaterial;
  86117. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  86118. /**
  86119. * Releases all associated resources
  86120. */
  86121. dispose(): void;
  86122. }
  86123. }
  86124. declare module BABYLON.GUI {
  86125. /**
  86126. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  86127. */
  86128. export class MeshButton3D extends Button3D {
  86129. /** @hidden */
  86130. protected _currentMesh: BABYLON.Mesh;
  86131. /**
  86132. * Creates a new 3D button based on a mesh
  86133. * @param mesh mesh to become a 3D button
  86134. * @param name defines the control name
  86135. */
  86136. constructor(mesh: BABYLON.Mesh, name?: string);
  86137. protected _getTypeName(): string;
  86138. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86139. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86140. }
  86141. }
  86142. declare module BABYLON.GUI {
  86143. /**
  86144. * Class used to create a container panel deployed on the surface of a plane
  86145. */
  86146. export class PlanePanel extends VolumeBasedPanel {
  86147. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86148. }
  86149. }
  86150. declare module BABYLON.GUI {
  86151. /**
  86152. * Class used to create a container panel where items get randomized planar mapping
  86153. */
  86154. export class ScatterPanel extends VolumeBasedPanel {
  86155. private _iteration;
  86156. /**
  86157. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  86158. */
  86159. get iteration(): BABYLON.float;
  86160. set iteration(value: BABYLON.float);
  86161. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86162. private _scatterMapping;
  86163. protected _finalProcessing(): void;
  86164. }
  86165. }
  86166. declare module BABYLON.GUI {
  86167. /**
  86168. * Class used to create a container panel deployed on the surface of a sphere
  86169. */
  86170. export class SpherePanel extends VolumeBasedPanel {
  86171. private _radius;
  86172. /**
  86173. * Gets or sets the radius of the sphere where to project controls (5 by default)
  86174. */
  86175. get radius(): BABYLON.float;
  86176. set radius(value: BABYLON.float);
  86177. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86178. private _sphericalMapping;
  86179. }
  86180. }
  86181. declare module BABYLON.GUI {
  86182. /**
  86183. * Class used to create a stack panel in 3D on XY plane
  86184. */
  86185. export class StackPanel3D extends Container3D {
  86186. private _isVertical;
  86187. /**
  86188. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  86189. */
  86190. get isVertical(): boolean;
  86191. set isVertical(value: boolean);
  86192. /**
  86193. * Gets or sets the distance between elements
  86194. */
  86195. margin: number;
  86196. /**
  86197. * Creates new StackPanel
  86198. * @param isVertical
  86199. */
  86200. constructor(isVertical?: boolean);
  86201. protected _arrangeChildren(): void;
  86202. }
  86203. }
  86204. declare module BABYLON {
  86205. /**
  86206. * Configuration for glTF validation
  86207. */
  86208. export interface IGLTFValidationConfiguration {
  86209. /**
  86210. * The url of the glTF validator.
  86211. */
  86212. url: string;
  86213. }
  86214. /**
  86215. * glTF validation
  86216. */
  86217. export class GLTFValidation {
  86218. /**
  86219. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  86220. */
  86221. static Configuration: IGLTFValidationConfiguration;
  86222. private static _LoadScriptPromise;
  86223. /**
  86224. * Validate a glTF asset using the glTF-Validator.
  86225. * @param data The JSON of a glTF or the array buffer of a binary glTF
  86226. * @param rootUrl The root url for the glTF
  86227. * @param fileName The file name for the glTF
  86228. * @param getExternalResource The callback to get external resources for the glTF validator
  86229. * @returns A promise that resolves with the glTF validation results once complete
  86230. */
  86231. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  86232. }
  86233. }
  86234. declare module BABYLON {
  86235. /**
  86236. * Mode that determines the coordinate system to use.
  86237. */
  86238. export enum GLTFLoaderCoordinateSystemMode {
  86239. /**
  86240. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  86241. */
  86242. AUTO = 0,
  86243. /**
  86244. * Sets the useRightHandedSystem flag on the scene.
  86245. */
  86246. FORCE_RIGHT_HANDED = 1
  86247. }
  86248. /**
  86249. * Mode that determines what animations will start.
  86250. */
  86251. export enum GLTFLoaderAnimationStartMode {
  86252. /**
  86253. * No animation will start.
  86254. */
  86255. NONE = 0,
  86256. /**
  86257. * The first animation will start.
  86258. */
  86259. FIRST = 1,
  86260. /**
  86261. * All animations will start.
  86262. */
  86263. ALL = 2
  86264. }
  86265. /**
  86266. * Interface that contains the data for the glTF asset.
  86267. */
  86268. export interface IGLTFLoaderData {
  86269. /**
  86270. * The object that represents the glTF JSON.
  86271. */
  86272. json: Object;
  86273. /**
  86274. * The BIN chunk of a binary glTF.
  86275. */
  86276. bin: Nullable<IDataBuffer>;
  86277. }
  86278. /**
  86279. * Interface for extending the loader.
  86280. */
  86281. export interface IGLTFLoaderExtension {
  86282. /**
  86283. * The name of this extension.
  86284. */
  86285. readonly name: string;
  86286. /**
  86287. * Defines whether this extension is enabled.
  86288. */
  86289. enabled: boolean;
  86290. /**
  86291. * Defines the order of this extension.
  86292. * The loader sorts the extensions using these values when loading.
  86293. */
  86294. order?: number;
  86295. }
  86296. /**
  86297. * Loader state.
  86298. */
  86299. export enum GLTFLoaderState {
  86300. /**
  86301. * The asset is loading.
  86302. */
  86303. LOADING = 0,
  86304. /**
  86305. * The asset is ready for rendering.
  86306. */
  86307. READY = 1,
  86308. /**
  86309. * The asset is completely loaded.
  86310. */
  86311. COMPLETE = 2
  86312. }
  86313. /** @hidden */
  86314. export interface IGLTFLoader extends IDisposable {
  86315. readonly state: Nullable<GLTFLoaderState>;
  86316. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  86317. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  86318. }
  86319. /**
  86320. * File loader for loading glTF files into a scene.
  86321. */
  86322. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  86323. /** @hidden */
  86324. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86325. /** @hidden */
  86326. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86327. /**
  86328. * Raised when the asset has been parsed
  86329. */
  86330. onParsedObservable: Observable<IGLTFLoaderData>;
  86331. private _onParsedObserver;
  86332. /**
  86333. * Raised when the asset has been parsed
  86334. */
  86335. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  86336. /**
  86337. * 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.
  86338. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  86339. * Defaults to true.
  86340. * @hidden
  86341. */
  86342. static IncrementalLoading: boolean;
  86343. /**
  86344. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  86345. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  86346. * @hidden
  86347. */
  86348. static HomogeneousCoordinates: boolean;
  86349. /**
  86350. * The coordinate system mode. Defaults to AUTO.
  86351. */
  86352. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  86353. /**
  86354. * The animation start mode. Defaults to FIRST.
  86355. */
  86356. animationStartMode: GLTFLoaderAnimationStartMode;
  86357. /**
  86358. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  86359. */
  86360. compileMaterials: boolean;
  86361. /**
  86362. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  86363. */
  86364. useClipPlane: boolean;
  86365. /**
  86366. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  86367. */
  86368. compileShadowGenerators: boolean;
  86369. /**
  86370. * Defines if the Alpha blended materials are only applied as coverage.
  86371. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  86372. * If true, no extra effects are applied to transparent pixels.
  86373. */
  86374. transparencyAsCoverage: boolean;
  86375. /**
  86376. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  86377. * Enabling will disable offline support and glTF validator.
  86378. * Defaults to false.
  86379. */
  86380. useRangeRequests: boolean;
  86381. /**
  86382. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  86383. */
  86384. createInstances: boolean;
  86385. /**
  86386. * 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.
  86387. */
  86388. alwaysComputeBoundingBox: boolean;
  86389. /**
  86390. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  86391. */
  86392. loadAllMaterials: boolean;
  86393. /**
  86394. * Function called before loading a url referenced by the asset.
  86395. */
  86396. preprocessUrlAsync: (url: string) => Promise<string>;
  86397. /**
  86398. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86399. * 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, ...)
  86400. */
  86401. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  86402. private _onMeshLoadedObserver;
  86403. /**
  86404. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86405. * 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, ...)
  86406. */
  86407. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  86408. /**
  86409. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  86410. */
  86411. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  86412. private _onTextureLoadedObserver;
  86413. /**
  86414. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  86415. */
  86416. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  86417. /**
  86418. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  86419. */
  86420. readonly onMaterialLoadedObservable: Observable<Material>;
  86421. private _onMaterialLoadedObserver;
  86422. /**
  86423. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  86424. */
  86425. set onMaterialLoaded(callback: (material: Material) => void);
  86426. /**
  86427. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  86428. */
  86429. readonly onCameraLoadedObservable: Observable<Camera>;
  86430. private _onCameraLoadedObserver;
  86431. /**
  86432. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  86433. */
  86434. set onCameraLoaded(callback: (camera: Camera) => void);
  86435. /**
  86436. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  86437. * For assets with LODs, raised when all of the LODs are complete.
  86438. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86439. */
  86440. readonly onCompleteObservable: Observable<void>;
  86441. private _onCompleteObserver;
  86442. /**
  86443. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  86444. * For assets with LODs, raised when all of the LODs are complete.
  86445. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86446. */
  86447. set onComplete(callback: () => void);
  86448. /**
  86449. * Observable raised when an error occurs.
  86450. */
  86451. readonly onErrorObservable: Observable<any>;
  86452. private _onErrorObserver;
  86453. /**
  86454. * Callback raised when an error occurs.
  86455. */
  86456. set onError(callback: (reason: any) => void);
  86457. /**
  86458. * Observable raised after the loader is disposed.
  86459. */
  86460. readonly onDisposeObservable: Observable<void>;
  86461. private _onDisposeObserver;
  86462. /**
  86463. * Callback raised after the loader is disposed.
  86464. */
  86465. set onDispose(callback: () => void);
  86466. /**
  86467. * Observable raised after a loader extension is created.
  86468. * Set additional options for a loader extension in this event.
  86469. */
  86470. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  86471. private _onExtensionLoadedObserver;
  86472. /**
  86473. * Callback raised after a loader extension is created.
  86474. */
  86475. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  86476. /**
  86477. * Defines if the loader logging is enabled.
  86478. */
  86479. get loggingEnabled(): boolean;
  86480. set loggingEnabled(value: boolean);
  86481. /**
  86482. * Defines if the loader should capture performance counters.
  86483. */
  86484. get capturePerformanceCounters(): boolean;
  86485. set capturePerformanceCounters(value: boolean);
  86486. /**
  86487. * Defines if the loader should validate the asset.
  86488. */
  86489. validate: boolean;
  86490. /**
  86491. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  86492. */
  86493. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  86494. private _onValidatedObserver;
  86495. /**
  86496. * Callback raised after a loader extension is created.
  86497. */
  86498. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  86499. private _loader;
  86500. private _progressCallback?;
  86501. private _requests;
  86502. private static magicBase64Encoded;
  86503. /**
  86504. * Name of the loader ("gltf")
  86505. */
  86506. name: string;
  86507. /** @hidden */
  86508. extensions: ISceneLoaderPluginExtensions;
  86509. /**
  86510. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  86511. */
  86512. dispose(): void;
  86513. /** @hidden */
  86514. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86515. /** @hidden */
  86516. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86517. /** @hidden */
  86518. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  86519. /** @hidden */
  86520. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  86521. /** @hidden */
  86522. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  86523. /** @hidden */
  86524. canDirectLoad(data: string): boolean;
  86525. /** @hidden */
  86526. directLoad(scene: Scene, data: string): Promise<any>;
  86527. /**
  86528. * The callback that allows custom handling of the root url based on the response url.
  86529. * @param rootUrl the original root url
  86530. * @param responseURL the response url if available
  86531. * @returns the new root url
  86532. */
  86533. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  86534. /** @hidden */
  86535. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  86536. /**
  86537. * The loader state or null if the loader is not active.
  86538. */
  86539. get loaderState(): Nullable<GLTFLoaderState>;
  86540. /**
  86541. * Returns a promise that resolves when the asset is completely loaded.
  86542. * @returns a promise that resolves when the asset is completely loaded.
  86543. */
  86544. whenCompleteAsync(): Promise<void>;
  86545. /** @hidden */
  86546. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  86547. /** @hidden */
  86548. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  86549. private _onProgress;
  86550. private _validate;
  86551. private _getLoader;
  86552. private _parseJson;
  86553. private _unpackBinaryAsync;
  86554. private _unpackBinaryV1Async;
  86555. private _unpackBinaryV2Async;
  86556. private static _parseVersion;
  86557. private static _compareVersion;
  86558. private static readonly _logSpaces;
  86559. private _logIndentLevel;
  86560. private _loggingEnabled;
  86561. /** @hidden */
  86562. _log: (message: string) => void;
  86563. /** @hidden */
  86564. _logOpen(message: string): void;
  86565. /** @hidden */
  86566. _logClose(): void;
  86567. private _logEnabled;
  86568. private _logDisabled;
  86569. private _capturePerformanceCounters;
  86570. /** @hidden */
  86571. _startPerformanceCounter: (counterName: string) => void;
  86572. /** @hidden */
  86573. _endPerformanceCounter: (counterName: string) => void;
  86574. private _startPerformanceCounterEnabled;
  86575. private _startPerformanceCounterDisabled;
  86576. private _endPerformanceCounterEnabled;
  86577. private _endPerformanceCounterDisabled;
  86578. }
  86579. }
  86580. declare module BABYLON.GLTF1 {
  86581. /**
  86582. * Enums
  86583. * @hidden
  86584. */
  86585. export enum EComponentType {
  86586. BYTE = 5120,
  86587. UNSIGNED_BYTE = 5121,
  86588. SHORT = 5122,
  86589. UNSIGNED_SHORT = 5123,
  86590. FLOAT = 5126
  86591. }
  86592. /** @hidden */
  86593. export enum EShaderType {
  86594. FRAGMENT = 35632,
  86595. VERTEX = 35633
  86596. }
  86597. /** @hidden */
  86598. export enum EParameterType {
  86599. BYTE = 5120,
  86600. UNSIGNED_BYTE = 5121,
  86601. SHORT = 5122,
  86602. UNSIGNED_SHORT = 5123,
  86603. INT = 5124,
  86604. UNSIGNED_INT = 5125,
  86605. FLOAT = 5126,
  86606. FLOAT_VEC2 = 35664,
  86607. FLOAT_VEC3 = 35665,
  86608. FLOAT_VEC4 = 35666,
  86609. INT_VEC2 = 35667,
  86610. INT_VEC3 = 35668,
  86611. INT_VEC4 = 35669,
  86612. BOOL = 35670,
  86613. BOOL_VEC2 = 35671,
  86614. BOOL_VEC3 = 35672,
  86615. BOOL_VEC4 = 35673,
  86616. FLOAT_MAT2 = 35674,
  86617. FLOAT_MAT3 = 35675,
  86618. FLOAT_MAT4 = 35676,
  86619. SAMPLER_2D = 35678
  86620. }
  86621. /** @hidden */
  86622. export enum ETextureWrapMode {
  86623. CLAMP_TO_EDGE = 33071,
  86624. MIRRORED_REPEAT = 33648,
  86625. REPEAT = 10497
  86626. }
  86627. /** @hidden */
  86628. export enum ETextureFilterType {
  86629. NEAREST = 9728,
  86630. LINEAR = 9728,
  86631. NEAREST_MIPMAP_NEAREST = 9984,
  86632. LINEAR_MIPMAP_NEAREST = 9985,
  86633. NEAREST_MIPMAP_LINEAR = 9986,
  86634. LINEAR_MIPMAP_LINEAR = 9987
  86635. }
  86636. /** @hidden */
  86637. export enum ETextureFormat {
  86638. ALPHA = 6406,
  86639. RGB = 6407,
  86640. RGBA = 6408,
  86641. LUMINANCE = 6409,
  86642. LUMINANCE_ALPHA = 6410
  86643. }
  86644. /** @hidden */
  86645. export enum ECullingType {
  86646. FRONT = 1028,
  86647. BACK = 1029,
  86648. FRONT_AND_BACK = 1032
  86649. }
  86650. /** @hidden */
  86651. export enum EBlendingFunction {
  86652. ZERO = 0,
  86653. ONE = 1,
  86654. SRC_COLOR = 768,
  86655. ONE_MINUS_SRC_COLOR = 769,
  86656. DST_COLOR = 774,
  86657. ONE_MINUS_DST_COLOR = 775,
  86658. SRC_ALPHA = 770,
  86659. ONE_MINUS_SRC_ALPHA = 771,
  86660. DST_ALPHA = 772,
  86661. ONE_MINUS_DST_ALPHA = 773,
  86662. CONSTANT_COLOR = 32769,
  86663. ONE_MINUS_CONSTANT_COLOR = 32770,
  86664. CONSTANT_ALPHA = 32771,
  86665. ONE_MINUS_CONSTANT_ALPHA = 32772,
  86666. SRC_ALPHA_SATURATE = 776
  86667. }
  86668. /** @hidden */
  86669. export interface IGLTFProperty {
  86670. extensions?: {
  86671. [key: string]: any;
  86672. };
  86673. extras?: Object;
  86674. }
  86675. /** @hidden */
  86676. export interface IGLTFChildRootProperty extends IGLTFProperty {
  86677. name?: string;
  86678. }
  86679. /** @hidden */
  86680. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  86681. bufferView: string;
  86682. byteOffset: number;
  86683. byteStride: number;
  86684. count: number;
  86685. type: string;
  86686. componentType: EComponentType;
  86687. max?: number[];
  86688. min?: number[];
  86689. name?: string;
  86690. }
  86691. /** @hidden */
  86692. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  86693. buffer: string;
  86694. byteOffset: number;
  86695. byteLength: number;
  86696. byteStride: number;
  86697. target?: number;
  86698. }
  86699. /** @hidden */
  86700. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  86701. uri: string;
  86702. byteLength?: number;
  86703. type?: string;
  86704. }
  86705. /** @hidden */
  86706. export interface IGLTFShader extends IGLTFChildRootProperty {
  86707. uri: string;
  86708. type: EShaderType;
  86709. }
  86710. /** @hidden */
  86711. export interface IGLTFProgram extends IGLTFChildRootProperty {
  86712. attributes: string[];
  86713. fragmentShader: string;
  86714. vertexShader: string;
  86715. }
  86716. /** @hidden */
  86717. export interface IGLTFTechniqueParameter {
  86718. type: number;
  86719. count?: number;
  86720. semantic?: string;
  86721. node?: string;
  86722. value?: number | boolean | string | Array<any>;
  86723. source?: string;
  86724. babylonValue?: any;
  86725. }
  86726. /** @hidden */
  86727. export interface IGLTFTechniqueCommonProfile {
  86728. lightingModel: string;
  86729. texcoordBindings: Object;
  86730. parameters?: Array<any>;
  86731. }
  86732. /** @hidden */
  86733. export interface IGLTFTechniqueStatesFunctions {
  86734. blendColor?: number[];
  86735. blendEquationSeparate?: number[];
  86736. blendFuncSeparate?: number[];
  86737. colorMask: boolean[];
  86738. cullFace: number[];
  86739. }
  86740. /** @hidden */
  86741. export interface IGLTFTechniqueStates {
  86742. enable: number[];
  86743. functions: IGLTFTechniqueStatesFunctions;
  86744. }
  86745. /** @hidden */
  86746. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  86747. parameters: {
  86748. [key: string]: IGLTFTechniqueParameter;
  86749. };
  86750. program: string;
  86751. attributes: {
  86752. [key: string]: string;
  86753. };
  86754. uniforms: {
  86755. [key: string]: string;
  86756. };
  86757. states: IGLTFTechniqueStates;
  86758. }
  86759. /** @hidden */
  86760. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  86761. technique?: string;
  86762. values: string[];
  86763. }
  86764. /** @hidden */
  86765. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  86766. attributes: {
  86767. [key: string]: string;
  86768. };
  86769. indices: string;
  86770. material: string;
  86771. mode?: number;
  86772. }
  86773. /** @hidden */
  86774. export interface IGLTFMesh extends IGLTFChildRootProperty {
  86775. primitives: IGLTFMeshPrimitive[];
  86776. }
  86777. /** @hidden */
  86778. export interface IGLTFImage extends IGLTFChildRootProperty {
  86779. uri: string;
  86780. }
  86781. /** @hidden */
  86782. export interface IGLTFSampler extends IGLTFChildRootProperty {
  86783. magFilter?: number;
  86784. minFilter?: number;
  86785. wrapS?: number;
  86786. wrapT?: number;
  86787. }
  86788. /** @hidden */
  86789. export interface IGLTFTexture extends IGLTFChildRootProperty {
  86790. sampler: string;
  86791. source: string;
  86792. format?: ETextureFormat;
  86793. internalFormat?: ETextureFormat;
  86794. target?: number;
  86795. type?: number;
  86796. babylonTexture?: Texture;
  86797. }
  86798. /** @hidden */
  86799. export interface IGLTFAmbienLight {
  86800. color?: number[];
  86801. }
  86802. /** @hidden */
  86803. export interface IGLTFDirectionalLight {
  86804. color?: number[];
  86805. }
  86806. /** @hidden */
  86807. export interface IGLTFPointLight {
  86808. color?: number[];
  86809. constantAttenuation?: number;
  86810. linearAttenuation?: number;
  86811. quadraticAttenuation?: number;
  86812. }
  86813. /** @hidden */
  86814. export interface IGLTFSpotLight {
  86815. color?: number[];
  86816. constantAttenuation?: number;
  86817. fallOfAngle?: number;
  86818. fallOffExponent?: number;
  86819. linearAttenuation?: number;
  86820. quadraticAttenuation?: number;
  86821. }
  86822. /** @hidden */
  86823. export interface IGLTFLight extends IGLTFChildRootProperty {
  86824. type: string;
  86825. }
  86826. /** @hidden */
  86827. export interface IGLTFCameraOrthographic {
  86828. xmag: number;
  86829. ymag: number;
  86830. zfar: number;
  86831. znear: number;
  86832. }
  86833. /** @hidden */
  86834. export interface IGLTFCameraPerspective {
  86835. aspectRatio: number;
  86836. yfov: number;
  86837. zfar: number;
  86838. znear: number;
  86839. }
  86840. /** @hidden */
  86841. export interface IGLTFCamera extends IGLTFChildRootProperty {
  86842. type: string;
  86843. }
  86844. /** @hidden */
  86845. export interface IGLTFAnimationChannelTarget {
  86846. id: string;
  86847. path: string;
  86848. }
  86849. /** @hidden */
  86850. export interface IGLTFAnimationChannel {
  86851. sampler: string;
  86852. target: IGLTFAnimationChannelTarget;
  86853. }
  86854. /** @hidden */
  86855. export interface IGLTFAnimationSampler {
  86856. input: string;
  86857. output: string;
  86858. interpolation?: string;
  86859. }
  86860. /** @hidden */
  86861. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  86862. channels?: IGLTFAnimationChannel[];
  86863. parameters?: {
  86864. [key: string]: string;
  86865. };
  86866. samplers?: {
  86867. [key: string]: IGLTFAnimationSampler;
  86868. };
  86869. }
  86870. /** @hidden */
  86871. export interface IGLTFNodeInstanceSkin {
  86872. skeletons: string[];
  86873. skin: string;
  86874. meshes: string[];
  86875. }
  86876. /** @hidden */
  86877. export interface IGLTFSkins extends IGLTFChildRootProperty {
  86878. bindShapeMatrix: number[];
  86879. inverseBindMatrices: string;
  86880. jointNames: string[];
  86881. babylonSkeleton?: Skeleton;
  86882. }
  86883. /** @hidden */
  86884. export interface IGLTFNode extends IGLTFChildRootProperty {
  86885. camera?: string;
  86886. children: string[];
  86887. skin?: string;
  86888. jointName?: string;
  86889. light?: string;
  86890. matrix: number[];
  86891. mesh?: string;
  86892. meshes?: string[];
  86893. rotation?: number[];
  86894. scale?: number[];
  86895. translation?: number[];
  86896. babylonNode?: Node;
  86897. }
  86898. /** @hidden */
  86899. export interface IGLTFScene extends IGLTFChildRootProperty {
  86900. nodes: string[];
  86901. }
  86902. /** @hidden */
  86903. export interface IGLTFRuntime {
  86904. extensions: {
  86905. [key: string]: any;
  86906. };
  86907. accessors: {
  86908. [key: string]: IGLTFAccessor;
  86909. };
  86910. buffers: {
  86911. [key: string]: IGLTFBuffer;
  86912. };
  86913. bufferViews: {
  86914. [key: string]: IGLTFBufferView;
  86915. };
  86916. meshes: {
  86917. [key: string]: IGLTFMesh;
  86918. };
  86919. lights: {
  86920. [key: string]: IGLTFLight;
  86921. };
  86922. cameras: {
  86923. [key: string]: IGLTFCamera;
  86924. };
  86925. nodes: {
  86926. [key: string]: IGLTFNode;
  86927. };
  86928. images: {
  86929. [key: string]: IGLTFImage;
  86930. };
  86931. textures: {
  86932. [key: string]: IGLTFTexture;
  86933. };
  86934. shaders: {
  86935. [key: string]: IGLTFShader;
  86936. };
  86937. programs: {
  86938. [key: string]: IGLTFProgram;
  86939. };
  86940. samplers: {
  86941. [key: string]: IGLTFSampler;
  86942. };
  86943. techniques: {
  86944. [key: string]: IGLTFTechnique;
  86945. };
  86946. materials: {
  86947. [key: string]: IGLTFMaterial;
  86948. };
  86949. animations: {
  86950. [key: string]: IGLTFAnimation;
  86951. };
  86952. skins: {
  86953. [key: string]: IGLTFSkins;
  86954. };
  86955. currentScene?: Object;
  86956. scenes: {
  86957. [key: string]: IGLTFScene;
  86958. };
  86959. extensionsUsed: string[];
  86960. extensionsRequired?: string[];
  86961. buffersCount: number;
  86962. shaderscount: number;
  86963. scene: Scene;
  86964. rootUrl: string;
  86965. loadedBufferCount: number;
  86966. loadedBufferViews: {
  86967. [name: string]: ArrayBufferView;
  86968. };
  86969. loadedShaderCount: number;
  86970. importOnlyMeshes: boolean;
  86971. importMeshesNames?: string[];
  86972. dummyNodes: Node[];
  86973. forAssetContainer: boolean;
  86974. }
  86975. /** @hidden */
  86976. export interface INodeToRoot {
  86977. bone: Bone;
  86978. node: IGLTFNode;
  86979. id: string;
  86980. }
  86981. /** @hidden */
  86982. export interface IJointNode {
  86983. node: IGLTFNode;
  86984. id: string;
  86985. }
  86986. }
  86987. declare module BABYLON.GLTF1 {
  86988. /**
  86989. * Utils functions for GLTF
  86990. * @hidden
  86991. */
  86992. export class GLTFUtils {
  86993. /**
  86994. * Sets the given "parameter" matrix
  86995. * @param scene: the Scene object
  86996. * @param source: the source node where to pick the matrix
  86997. * @param parameter: the GLTF technique parameter
  86998. * @param uniformName: the name of the shader's uniform
  86999. * @param shaderMaterial: the shader material
  87000. */
  87001. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  87002. /**
  87003. * Sets the given "parameter" matrix
  87004. * @param shaderMaterial: the shader material
  87005. * @param uniform: the name of the shader's uniform
  87006. * @param value: the value of the uniform
  87007. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  87008. */
  87009. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  87010. /**
  87011. * Returns the wrap mode of the texture
  87012. * @param mode: the mode value
  87013. */
  87014. static GetWrapMode(mode: number): number;
  87015. /**
  87016. * Returns the byte stride giving an accessor
  87017. * @param accessor: the GLTF accessor objet
  87018. */
  87019. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  87020. /**
  87021. * Returns the texture filter mode giving a mode value
  87022. * @param mode: the filter mode value
  87023. */
  87024. static GetTextureFilterMode(mode: number): ETextureFilterType;
  87025. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  87026. /**
  87027. * Returns a buffer from its accessor
  87028. * @param gltfRuntime: the GLTF runtime
  87029. * @param accessor: the GLTF accessor
  87030. */
  87031. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  87032. /**
  87033. * Decodes a buffer view into a string
  87034. * @param view: the buffer view
  87035. */
  87036. static DecodeBufferToText(view: ArrayBufferView): string;
  87037. /**
  87038. * Returns the default material of gltf. Related to
  87039. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  87040. * @param scene: the Babylon.js scene
  87041. */
  87042. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  87043. private static _DefaultMaterial;
  87044. }
  87045. }
  87046. declare module BABYLON.GLTF1 {
  87047. /**
  87048. * Implementation of the base glTF spec
  87049. * @hidden
  87050. */
  87051. export class GLTFLoaderBase {
  87052. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  87053. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87054. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  87055. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87056. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  87057. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87058. }
  87059. /**
  87060. * glTF V1 Loader
  87061. * @hidden
  87062. */
  87063. export class GLTFLoader implements IGLTFLoader {
  87064. static Extensions: {
  87065. [name: string]: GLTFLoaderExtension;
  87066. };
  87067. static RegisterExtension(extension: GLTFLoaderExtension): void;
  87068. state: Nullable<GLTFLoaderState>;
  87069. dispose(): void;
  87070. private _importMeshAsync;
  87071. /**
  87072. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  87073. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  87074. * @param scene the scene the meshes should be added to
  87075. * @param forAssetContainer defines if the entities must be stored in the scene
  87076. * @param data gltf data containing information of the meshes in a loaded file
  87077. * @param rootUrl root url to load from
  87078. * @param onProgress event that fires when loading progress has occured
  87079. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  87080. */
  87081. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  87082. private _loadAsync;
  87083. /**
  87084. * Imports all objects from a loaded gltf file and adds them to the scene
  87085. * @param scene the scene the objects should be added to
  87086. * @param data gltf data containing information of the meshes in a loaded file
  87087. * @param rootUrl root url to load from
  87088. * @param onProgress event that fires when loading progress has occured
  87089. * @returns a promise which completes when objects have been loaded to the scene
  87090. */
  87091. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  87092. private _loadShadersAsync;
  87093. private _loadBuffersAsync;
  87094. private _createNodes;
  87095. }
  87096. /** @hidden */
  87097. export abstract class GLTFLoaderExtension {
  87098. private _name;
  87099. constructor(name: string);
  87100. get name(): string;
  87101. /**
  87102. * Defines an override for loading the runtime
  87103. * Return true to stop further extensions from loading the runtime
  87104. */
  87105. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  87106. /**
  87107. * Defines an onverride for creating gltf runtime
  87108. * Return true to stop further extensions from creating the runtime
  87109. */
  87110. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  87111. /**
  87112. * Defines an override for loading buffers
  87113. * Return true to stop further extensions from loading this buffer
  87114. */
  87115. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  87116. /**
  87117. * Defines an override for loading texture buffers
  87118. * Return true to stop further extensions from loading this texture data
  87119. */
  87120. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87121. /**
  87122. * Defines an override for creating textures
  87123. * Return true to stop further extensions from loading this texture
  87124. */
  87125. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  87126. /**
  87127. * Defines an override for loading shader strings
  87128. * Return true to stop further extensions from loading this shader data
  87129. */
  87130. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87131. /**
  87132. * Defines an override for loading materials
  87133. * Return true to stop further extensions from loading this material
  87134. */
  87135. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87136. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  87137. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  87138. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87139. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87140. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  87141. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87142. private static LoadTextureBufferAsync;
  87143. private static CreateTextureAsync;
  87144. private static ApplyExtensions;
  87145. }
  87146. }
  87147. declare module BABYLON.GLTF1 {
  87148. /** @hidden */
  87149. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  87150. private _bin;
  87151. constructor();
  87152. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  87153. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87154. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87155. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87156. }
  87157. }
  87158. declare module BABYLON.GLTF1 {
  87159. /** @hidden */
  87160. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  87161. constructor();
  87162. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  87163. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87164. private _loadTexture;
  87165. }
  87166. }
  87167. declare module BABYLON.GLTF2.Loader {
  87168. /**
  87169. * Loader interface with an index field.
  87170. */
  87171. export interface IArrayItem {
  87172. /**
  87173. * The index of this item in the array.
  87174. */
  87175. index: number;
  87176. }
  87177. /**
  87178. * Loader interface with additional members.
  87179. */
  87180. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  87181. /** @hidden */
  87182. _data?: Promise<ArrayBufferView>;
  87183. /** @hidden */
  87184. _babylonVertexBuffer?: Promise<VertexBuffer>;
  87185. }
  87186. /**
  87187. * Loader interface with additional members.
  87188. */
  87189. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  87190. }
  87191. /** @hidden */
  87192. export interface _IAnimationSamplerData {
  87193. input: Float32Array;
  87194. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  87195. output: Float32Array;
  87196. }
  87197. /**
  87198. * Loader interface with additional members.
  87199. */
  87200. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  87201. /** @hidden */
  87202. _data?: Promise<_IAnimationSamplerData>;
  87203. }
  87204. /**
  87205. * Loader interface with additional members.
  87206. */
  87207. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  87208. channels: IAnimationChannel[];
  87209. samplers: IAnimationSampler[];
  87210. /** @hidden */
  87211. _babylonAnimationGroup?: AnimationGroup;
  87212. }
  87213. /**
  87214. * Loader interface with additional members.
  87215. */
  87216. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  87217. /** @hidden */
  87218. _data?: Promise<ArrayBufferView>;
  87219. }
  87220. /**
  87221. * Loader interface with additional members.
  87222. */
  87223. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  87224. /** @hidden */
  87225. _data?: Promise<ArrayBufferView>;
  87226. /** @hidden */
  87227. _babylonBuffer?: Promise<Buffer>;
  87228. }
  87229. /**
  87230. * Loader interface with additional members.
  87231. */
  87232. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  87233. }
  87234. /**
  87235. * Loader interface with additional members.
  87236. */
  87237. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  87238. /** @hidden */
  87239. _data?: Promise<ArrayBufferView>;
  87240. }
  87241. /**
  87242. * Loader interface with additional members.
  87243. */
  87244. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  87245. }
  87246. /**
  87247. * Loader interface with additional members.
  87248. */
  87249. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  87250. }
  87251. /**
  87252. * Loader interface with additional members.
  87253. */
  87254. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  87255. baseColorTexture?: ITextureInfo;
  87256. metallicRoughnessTexture?: ITextureInfo;
  87257. }
  87258. /**
  87259. * Loader interface with additional members.
  87260. */
  87261. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  87262. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  87263. normalTexture?: IMaterialNormalTextureInfo;
  87264. occlusionTexture?: IMaterialOcclusionTextureInfo;
  87265. emissiveTexture?: ITextureInfo;
  87266. /** @hidden */
  87267. _data?: {
  87268. [babylonDrawMode: number]: {
  87269. babylonMaterial: Material;
  87270. babylonMeshes: AbstractMesh[];
  87271. promise: Promise<void>;
  87272. };
  87273. };
  87274. }
  87275. /**
  87276. * Loader interface with additional members.
  87277. */
  87278. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  87279. primitives: IMeshPrimitive[];
  87280. }
  87281. /**
  87282. * Loader interface with additional members.
  87283. */
  87284. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  87285. /** @hidden */
  87286. _instanceData?: {
  87287. babylonSourceMesh: Mesh;
  87288. promise: Promise<any>;
  87289. };
  87290. }
  87291. /**
  87292. * Loader interface with additional members.
  87293. */
  87294. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  87295. /**
  87296. * The parent glTF node.
  87297. */
  87298. parent?: INode;
  87299. /** @hidden */
  87300. _babylonTransformNode?: TransformNode;
  87301. /** @hidden */
  87302. _primitiveBabylonMeshes?: AbstractMesh[];
  87303. /** @hidden */
  87304. _babylonBones?: Bone[];
  87305. /** @hidden */
  87306. _numMorphTargets?: number;
  87307. }
  87308. /** @hidden */
  87309. export interface _ISamplerData {
  87310. noMipMaps: boolean;
  87311. samplingMode: number;
  87312. wrapU: number;
  87313. wrapV: number;
  87314. }
  87315. /**
  87316. * Loader interface with additional members.
  87317. */
  87318. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  87319. /** @hidden */
  87320. _data?: _ISamplerData;
  87321. }
  87322. /**
  87323. * Loader interface with additional members.
  87324. */
  87325. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  87326. }
  87327. /**
  87328. * Loader interface with additional members.
  87329. */
  87330. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  87331. /** @hidden */
  87332. _data?: {
  87333. babylonSkeleton: Skeleton;
  87334. promise: Promise<void>;
  87335. };
  87336. }
  87337. /**
  87338. * Loader interface with additional members.
  87339. */
  87340. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  87341. /** @hidden */
  87342. _textureInfo: ITextureInfo;
  87343. }
  87344. /**
  87345. * Loader interface with additional members.
  87346. */
  87347. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  87348. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  87349. nonColorData?: boolean;
  87350. }
  87351. /**
  87352. * Loader interface with additional members.
  87353. */
  87354. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  87355. accessors?: IAccessor[];
  87356. animations?: IAnimation[];
  87357. buffers?: IBuffer[];
  87358. bufferViews?: IBufferView[];
  87359. cameras?: ICamera[];
  87360. images?: IImage[];
  87361. materials?: IMaterial[];
  87362. meshes?: IMesh[];
  87363. nodes?: INode[];
  87364. samplers?: ISampler[];
  87365. scenes?: IScene[];
  87366. skins?: ISkin[];
  87367. textures?: ITexture[];
  87368. }
  87369. }
  87370. declare module BABYLON.GLTF2 {
  87371. /**
  87372. * Interface for a glTF loader extension.
  87373. */
  87374. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  87375. /**
  87376. * Called after the loader state changes to LOADING.
  87377. */
  87378. onLoading?(): void;
  87379. /**
  87380. * Called after the loader state changes to READY.
  87381. */
  87382. onReady?(): void;
  87383. /**
  87384. * Define this method to modify the default behavior when loading scenes.
  87385. * @param context The context when loading the asset
  87386. * @param scene The glTF scene property
  87387. * @returns A promise that resolves when the load is complete or null if not handled
  87388. */
  87389. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  87390. /**
  87391. * Define this method to modify the default behavior when loading nodes.
  87392. * @param context The context when loading the asset
  87393. * @param node The glTF node property
  87394. * @param assign A function called synchronously after parsing the glTF properties
  87395. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  87396. */
  87397. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87398. /**
  87399. * Define this method to modify the default behavior when loading cameras.
  87400. * @param context The context when loading the asset
  87401. * @param camera The glTF camera property
  87402. * @param assign A function called synchronously after parsing the glTF properties
  87403. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  87404. */
  87405. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  87406. /**
  87407. * @hidden
  87408. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  87409. * @param context The context when loading the asset
  87410. * @param primitive The glTF mesh primitive property
  87411. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  87412. */
  87413. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  87414. /**
  87415. * @hidden
  87416. * Define this method to modify the default behavior when loading data for mesh primitives.
  87417. * @param context The context when loading the asset
  87418. * @param name The mesh name when loading the asset
  87419. * @param node The glTF node when loading the asset
  87420. * @param mesh The glTF mesh when loading the asset
  87421. * @param primitive The glTF mesh primitive property
  87422. * @param assign A function called synchronously after parsing the glTF properties
  87423. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87424. */
  87425. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  87426. /**
  87427. * @hidden
  87428. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  87429. * @param context The context when loading the asset
  87430. * @param material The glTF material property
  87431. * @param assign A function called synchronously after parsing the glTF properties
  87432. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  87433. */
  87434. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  87435. /**
  87436. * Define this method to modify the default behavior when creating materials.
  87437. * @param context The context when loading the asset
  87438. * @param material The glTF material property
  87439. * @param babylonDrawMode The draw mode for the Babylon material
  87440. * @returns The Babylon material or null if not handled
  87441. */
  87442. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  87443. /**
  87444. * Define this method to modify the default behavior when loading material properties.
  87445. * @param context The context when loading the asset
  87446. * @param material The glTF material property
  87447. * @param babylonMaterial The Babylon material
  87448. * @returns A promise that resolves when the load is complete or null if not handled
  87449. */
  87450. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87451. /**
  87452. * Define this method to modify the default behavior when loading texture infos.
  87453. * @param context The context when loading the asset
  87454. * @param textureInfo The glTF texture info property
  87455. * @param assign A function called synchronously after parsing the glTF properties
  87456. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87457. */
  87458. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87459. /**
  87460. * @hidden
  87461. * Define this method to modify the default behavior when loading textures.
  87462. * @param context The context when loading the asset
  87463. * @param texture The glTF texture property
  87464. * @param assign A function called synchronously after parsing the glTF properties
  87465. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87466. */
  87467. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87468. /**
  87469. * Define this method to modify the default behavior when loading animations.
  87470. * @param context The context when loading the asset
  87471. * @param animation The glTF animation property
  87472. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  87473. */
  87474. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  87475. /**
  87476. * @hidden
  87477. * Define this method to modify the default behavior when loading skins.
  87478. * @param context The context when loading the asset
  87479. * @param node The glTF node property
  87480. * @param skin The glTF skin property
  87481. * @returns A promise that resolves when the load is complete or null if not handled
  87482. */
  87483. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  87484. /**
  87485. * @hidden
  87486. * Define this method to modify the default behavior when loading uris.
  87487. * @param context The context when loading the asset
  87488. * @param property The glTF property associated with the uri
  87489. * @param uri The uri to load
  87490. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87491. */
  87492. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  87493. /**
  87494. * Define this method to modify the default behavior when loading buffer views.
  87495. * @param context The context when loading the asset
  87496. * @param bufferView The glTF buffer view property
  87497. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87498. */
  87499. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  87500. /**
  87501. * Define this method to modify the default behavior when loading buffers.
  87502. * @param context The context when loading the asset
  87503. * @param buffer The glTF buffer property
  87504. * @param byteOffset The byte offset to load
  87505. * @param byteLength The byte length to load
  87506. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87507. */
  87508. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  87509. }
  87510. }
  87511. declare module BABYLON.GLTF2 {
  87512. /**
  87513. * Helper class for working with arrays when loading the glTF asset
  87514. */
  87515. export class ArrayItem {
  87516. /**
  87517. * Gets an item from the given array.
  87518. * @param context The context when loading the asset
  87519. * @param array The array to get the item from
  87520. * @param index The index to the array
  87521. * @returns The array item
  87522. */
  87523. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  87524. /**
  87525. * Assign an `index` field to each item of the given array.
  87526. * @param array The array of items
  87527. */
  87528. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  87529. }
  87530. /**
  87531. * The glTF 2.0 loader
  87532. */
  87533. export class GLTFLoader implements IGLTFLoader {
  87534. /** @hidden */
  87535. _completePromises: Promise<any>[];
  87536. /** @hidden */
  87537. _forAssetContainer: boolean;
  87538. /** Storage */
  87539. _babylonLights: Light[];
  87540. /** @hidden */
  87541. _disableInstancedMesh: number;
  87542. private _disposed;
  87543. private _parent;
  87544. private _state;
  87545. private _extensions;
  87546. private _rootUrl;
  87547. private _fileName;
  87548. private _uniqueRootUrl;
  87549. private _gltf;
  87550. private _bin;
  87551. private _babylonScene;
  87552. private _rootBabylonMesh;
  87553. private _defaultBabylonMaterialData;
  87554. private static _RegisteredExtensions;
  87555. /**
  87556. * The default glTF sampler.
  87557. */
  87558. static readonly DefaultSampler: ISampler;
  87559. /**
  87560. * Registers a loader extension.
  87561. * @param name The name of the loader extension.
  87562. * @param factory The factory function that creates the loader extension.
  87563. */
  87564. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  87565. /**
  87566. * Unregisters a loader extension.
  87567. * @param name The name of the loader extension.
  87568. * @returns A boolean indicating whether the extension has been unregistered
  87569. */
  87570. static UnregisterExtension(name: string): boolean;
  87571. /**
  87572. * The loader state.
  87573. */
  87574. get state(): Nullable<GLTFLoaderState>;
  87575. /**
  87576. * The object that represents the glTF JSON.
  87577. */
  87578. get gltf(): IGLTF;
  87579. /**
  87580. * The BIN chunk of a binary glTF.
  87581. */
  87582. get bin(): Nullable<IDataBuffer>;
  87583. /**
  87584. * The parent file loader.
  87585. */
  87586. get parent(): GLTFFileLoader;
  87587. /**
  87588. * The Babylon scene when loading the asset.
  87589. */
  87590. get babylonScene(): Scene;
  87591. /**
  87592. * The root Babylon mesh when loading the asset.
  87593. */
  87594. get rootBabylonMesh(): Mesh;
  87595. /** @hidden */
  87596. constructor(parent: GLTFFileLoader);
  87597. /** @hidden */
  87598. dispose(): void;
  87599. /** @hidden */
  87600. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87601. /** @hidden */
  87602. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87603. private _loadAsync;
  87604. private _loadData;
  87605. private _setupData;
  87606. private _loadExtensions;
  87607. private _checkExtensions;
  87608. private _setState;
  87609. private _createRootNode;
  87610. /**
  87611. * Loads a glTF scene.
  87612. * @param context The context when loading the asset
  87613. * @param scene The glTF scene property
  87614. * @returns A promise that resolves when the load is complete
  87615. */
  87616. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  87617. private _forEachPrimitive;
  87618. private _getGeometries;
  87619. private _getMeshes;
  87620. private _getTransformNodes;
  87621. private _getSkeletons;
  87622. private _getAnimationGroups;
  87623. private _startAnimations;
  87624. /**
  87625. * Loads a glTF node.
  87626. * @param context The context when loading the asset
  87627. * @param node The glTF node property
  87628. * @param assign A function called synchronously after parsing the glTF properties
  87629. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  87630. */
  87631. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  87632. private _loadMeshAsync;
  87633. /**
  87634. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  87635. * @param context The context when loading the asset
  87636. * @param name The mesh name when loading the asset
  87637. * @param node The glTF node when loading the asset
  87638. * @param mesh The glTF mesh when loading the asset
  87639. * @param primitive The glTF mesh primitive property
  87640. * @param assign A function called synchronously after parsing the glTF properties
  87641. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87642. */
  87643. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  87644. private _loadVertexDataAsync;
  87645. private _createMorphTargets;
  87646. private _loadMorphTargetsAsync;
  87647. private _loadMorphTargetVertexDataAsync;
  87648. private static _LoadTransform;
  87649. private _loadSkinAsync;
  87650. private _loadBones;
  87651. private _loadBone;
  87652. private _loadSkinInverseBindMatricesDataAsync;
  87653. private _updateBoneMatrices;
  87654. private _getNodeMatrix;
  87655. /**
  87656. * Loads a glTF camera.
  87657. * @param context The context when loading the asset
  87658. * @param camera The glTF camera property
  87659. * @param assign A function called synchronously after parsing the glTF properties
  87660. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  87661. */
  87662. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  87663. private _loadAnimationsAsync;
  87664. /**
  87665. * Loads a glTF animation.
  87666. * @param context The context when loading the asset
  87667. * @param animation The glTF animation property
  87668. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  87669. */
  87670. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  87671. /**
  87672. * @hidden Loads a glTF animation channel.
  87673. * @param context The context when loading the asset
  87674. * @param animationContext The context of the animation when loading the asset
  87675. * @param animation The glTF animation property
  87676. * @param channel The glTF animation channel property
  87677. * @param babylonAnimationGroup The babylon animation group property
  87678. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  87679. * @returns A void promise when the channel load is complete
  87680. */
  87681. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  87682. private _loadAnimationSamplerAsync;
  87683. /**
  87684. * Loads a glTF buffer.
  87685. * @param context The context when loading the asset
  87686. * @param buffer The glTF buffer property
  87687. * @param byteOffset The byte offset to use
  87688. * @param byteLength The byte length to use
  87689. * @returns A promise that resolves with the loaded data when the load is complete
  87690. */
  87691. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  87692. /**
  87693. * Loads a glTF buffer view.
  87694. * @param context The context when loading the asset
  87695. * @param bufferView The glTF buffer view property
  87696. * @returns A promise that resolves with the loaded data when the load is complete
  87697. */
  87698. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  87699. private _loadAccessorAsync;
  87700. /** @hidden */
  87701. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  87702. private _loadIndicesAccessorAsync;
  87703. private _loadVertexBufferViewAsync;
  87704. private _loadVertexAccessorAsync;
  87705. private _loadMaterialMetallicRoughnessPropertiesAsync;
  87706. /** @hidden */
  87707. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  87708. private _createDefaultMaterial;
  87709. /**
  87710. * Creates a Babylon material from a glTF material.
  87711. * @param context The context when loading the asset
  87712. * @param material The glTF material property
  87713. * @param babylonDrawMode The draw mode for the Babylon material
  87714. * @returns The Babylon material
  87715. */
  87716. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  87717. /**
  87718. * Loads properties from a glTF material into a Babylon material.
  87719. * @param context The context when loading the asset
  87720. * @param material The glTF material property
  87721. * @param babylonMaterial The Babylon material
  87722. * @returns A promise that resolves when the load is complete
  87723. */
  87724. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  87725. /**
  87726. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  87727. * @param context The context when loading the asset
  87728. * @param material The glTF material property
  87729. * @param babylonMaterial The Babylon material
  87730. * @returns A promise that resolves when the load is complete
  87731. */
  87732. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  87733. /**
  87734. * Loads the alpha properties from a glTF material into a Babylon material.
  87735. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  87736. * @param context The context when loading the asset
  87737. * @param material The glTF material property
  87738. * @param babylonMaterial The Babylon material
  87739. */
  87740. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  87741. /**
  87742. * Loads a glTF texture info.
  87743. * @param context The context when loading the asset
  87744. * @param textureInfo The glTF texture info property
  87745. * @param assign A function called synchronously after parsing the glTF properties
  87746. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  87747. */
  87748. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  87749. /** @hidden */
  87750. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  87751. /** @hidden */
  87752. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  87753. private _loadSampler;
  87754. /**
  87755. * Loads a glTF image.
  87756. * @param context The context when loading the asset
  87757. * @param image The glTF image property
  87758. * @returns A promise that resolves with the loaded data when the load is complete
  87759. */
  87760. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  87761. /**
  87762. * Loads a glTF uri.
  87763. * @param context The context when loading the asset
  87764. * @param property The glTF property associated with the uri
  87765. * @param uri The base64 or relative uri
  87766. * @returns A promise that resolves with the loaded data when the load is complete
  87767. */
  87768. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  87769. /**
  87770. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  87771. * @param babylonObject the Babylon object with metadata
  87772. * @param pointer the JSON pointer
  87773. */
  87774. static AddPointerMetadata(babylonObject: {
  87775. metadata: any;
  87776. }, pointer: string): void;
  87777. private static _GetTextureWrapMode;
  87778. private static _GetTextureSamplingMode;
  87779. private static _GetTypedArrayConstructor;
  87780. private static _GetTypedArray;
  87781. private static _GetNumComponents;
  87782. private static _ValidateUri;
  87783. /** @hidden */
  87784. static _GetDrawMode(context: string, mode: number | undefined): number;
  87785. private _compileMaterialsAsync;
  87786. private _compileShadowGeneratorsAsync;
  87787. private _forEachExtensions;
  87788. private _applyExtensions;
  87789. private _extensionsOnLoading;
  87790. private _extensionsOnReady;
  87791. private _extensionsLoadSceneAsync;
  87792. private _extensionsLoadNodeAsync;
  87793. private _extensionsLoadCameraAsync;
  87794. private _extensionsLoadVertexDataAsync;
  87795. private _extensionsLoadMeshPrimitiveAsync;
  87796. private _extensionsLoadMaterialAsync;
  87797. private _extensionsCreateMaterial;
  87798. private _extensionsLoadMaterialPropertiesAsync;
  87799. private _extensionsLoadTextureInfoAsync;
  87800. private _extensionsLoadTextureAsync;
  87801. private _extensionsLoadAnimationAsync;
  87802. private _extensionsLoadSkinAsync;
  87803. private _extensionsLoadUriAsync;
  87804. private _extensionsLoadBufferViewAsync;
  87805. private _extensionsLoadBufferAsync;
  87806. /**
  87807. * Helper method called by a loader extension to load an glTF extension.
  87808. * @param context The context when loading the asset
  87809. * @param property The glTF property to load the extension from
  87810. * @param extensionName The name of the extension to load
  87811. * @param actionAsync The action to run
  87812. * @returns The promise returned by actionAsync or null if the extension does not exist
  87813. */
  87814. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  87815. /**
  87816. * Helper method called by a loader extension to load a glTF extra.
  87817. * @param context The context when loading the asset
  87818. * @param property The glTF property to load the extra from
  87819. * @param extensionName The name of the extension to load
  87820. * @param actionAsync The action to run
  87821. * @returns The promise returned by actionAsync or null if the extra does not exist
  87822. */
  87823. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  87824. /**
  87825. * Checks for presence of an extension.
  87826. * @param name The name of the extension to check
  87827. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  87828. */
  87829. isExtensionUsed(name: string): boolean;
  87830. /**
  87831. * Increments the indentation level and logs a message.
  87832. * @param message The message to log
  87833. */
  87834. logOpen(message: string): void;
  87835. /**
  87836. * Decrements the indentation level.
  87837. */
  87838. logClose(): void;
  87839. /**
  87840. * Logs a message
  87841. * @param message The message to log
  87842. */
  87843. log(message: string): void;
  87844. /**
  87845. * Starts a performance counter.
  87846. * @param counterName The name of the performance counter
  87847. */
  87848. startPerformanceCounter(counterName: string): void;
  87849. /**
  87850. * Ends a performance counter.
  87851. * @param counterName The name of the performance counter
  87852. */
  87853. endPerformanceCounter(counterName: string): void;
  87854. }
  87855. }
  87856. declare module BABYLON.GLTF2.Loader.Extensions {
  87857. /** @hidden */
  87858. interface IEXTLightsImageBased_LightImageBased {
  87859. _babylonTexture?: BaseTexture;
  87860. _loaded?: Promise<void>;
  87861. }
  87862. /**
  87863. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  87864. */
  87865. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  87866. /**
  87867. * The name of this extension.
  87868. */
  87869. readonly name: string;
  87870. /**
  87871. * Defines whether this extension is enabled.
  87872. */
  87873. enabled: boolean;
  87874. private _loader;
  87875. private _lights?;
  87876. /** @hidden */
  87877. constructor(loader: GLTFLoader);
  87878. /** @hidden */
  87879. dispose(): void;
  87880. /** @hidden */
  87881. onLoading(): void;
  87882. /** @hidden */
  87883. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  87884. private _loadLightAsync;
  87885. }
  87886. }
  87887. declare module BABYLON.GLTF2.Loader.Extensions {
  87888. /**
  87889. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  87890. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  87891. * !!! Experimental Extension Subject to Changes !!!
  87892. */
  87893. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  87894. /**
  87895. * The name of this extension.
  87896. */
  87897. readonly name: string;
  87898. /**
  87899. * Defines whether this extension is enabled.
  87900. */
  87901. enabled: boolean;
  87902. private _loader;
  87903. /** @hidden */
  87904. constructor(loader: GLTFLoader);
  87905. /** @hidden */
  87906. dispose(): void;
  87907. /** @hidden */
  87908. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87909. }
  87910. }
  87911. declare module BABYLON.GLTF2.Loader.Extensions {
  87912. /**
  87913. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  87914. *
  87915. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  87916. */
  87917. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  87918. /**
  87919. * The name of this extension.
  87920. */
  87921. readonly name: string;
  87922. /**
  87923. * Defines whether this extension is enabled.
  87924. */
  87925. enabled: boolean;
  87926. /**
  87927. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  87928. */
  87929. static DecoderPath: string;
  87930. private _loader;
  87931. private _decoderPromise?;
  87932. /** @hidden */
  87933. constructor(loader: GLTFLoader);
  87934. /** @hidden */
  87935. dispose(): void;
  87936. /** @hidden */
  87937. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  87938. }
  87939. }
  87940. declare module BABYLON.GLTF2.Loader.Extensions {
  87941. /**
  87942. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  87943. */
  87944. export class EXT_texture_webp implements IGLTFLoaderExtension {
  87945. /** The name of this extension. */
  87946. readonly name: string;
  87947. /** Defines whether this extension is enabled. */
  87948. enabled: boolean;
  87949. private _loader;
  87950. /** @hidden */
  87951. constructor(loader: GLTFLoader);
  87952. /** @hidden */
  87953. dispose(): void;
  87954. /** @hidden */
  87955. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87956. }
  87957. }
  87958. declare module BABYLON.GLTF2.Loader.Extensions {
  87959. /**
  87960. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  87961. */
  87962. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  87963. /**
  87964. * The name of this extension.
  87965. */
  87966. readonly name: string;
  87967. /**
  87968. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  87969. */
  87970. dracoCompression?: DracoCompression;
  87971. /**
  87972. * Defines whether this extension is enabled.
  87973. */
  87974. enabled: boolean;
  87975. private _loader;
  87976. /** @hidden */
  87977. constructor(loader: GLTFLoader);
  87978. /** @hidden */
  87979. dispose(): void;
  87980. /** @hidden */
  87981. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  87982. }
  87983. }
  87984. declare module BABYLON.GLTF2.Loader.Extensions {
  87985. /**
  87986. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  87987. */
  87988. export class KHR_lights implements IGLTFLoaderExtension {
  87989. /**
  87990. * The name of this extension.
  87991. */
  87992. readonly name: string;
  87993. /**
  87994. * Defines whether this extension is enabled.
  87995. */
  87996. enabled: boolean;
  87997. private _loader;
  87998. private _lights?;
  87999. /** @hidden */
  88000. constructor(loader: GLTFLoader);
  88001. /** @hidden */
  88002. dispose(): void;
  88003. /** @hidden */
  88004. onLoading(): void;
  88005. /** @hidden */
  88006. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88007. }
  88008. }
  88009. declare module BABYLON.GLTF2.Loader.Extensions {
  88010. /**
  88011. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  88012. */
  88013. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  88014. /**
  88015. * The name of this extension.
  88016. */
  88017. readonly name: string;
  88018. /**
  88019. * Defines whether this extension is enabled.
  88020. */
  88021. enabled: boolean;
  88022. /**
  88023. * Defines a number that determines the order the extensions are applied.
  88024. */
  88025. order: number;
  88026. private _loader;
  88027. /** @hidden */
  88028. constructor(loader: GLTFLoader);
  88029. /** @hidden */
  88030. dispose(): void;
  88031. /** @hidden */
  88032. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88033. private _loadSpecularGlossinessPropertiesAsync;
  88034. }
  88035. }
  88036. declare module BABYLON.GLTF2.Loader.Extensions {
  88037. /**
  88038. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  88039. */
  88040. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  88041. /**
  88042. * The name of this extension.
  88043. */
  88044. readonly name: string;
  88045. /**
  88046. * Defines whether this extension is enabled.
  88047. */
  88048. enabled: boolean;
  88049. /**
  88050. * Defines a number that determines the order the extensions are applied.
  88051. */
  88052. order: number;
  88053. private _loader;
  88054. /** @hidden */
  88055. constructor(loader: GLTFLoader);
  88056. /** @hidden */
  88057. dispose(): void;
  88058. /** @hidden */
  88059. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88060. private _loadUnlitPropertiesAsync;
  88061. }
  88062. }
  88063. declare module BABYLON.GLTF2.Loader.Extensions {
  88064. /**
  88065. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  88066. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  88067. */
  88068. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  88069. /**
  88070. * The name of this extension.
  88071. */
  88072. readonly name: string;
  88073. /**
  88074. * Defines whether this extension is enabled.
  88075. */
  88076. enabled: boolean;
  88077. /**
  88078. * Defines a number that determines the order the extensions are applied.
  88079. */
  88080. order: number;
  88081. private _loader;
  88082. /** @hidden */
  88083. constructor(loader: GLTFLoader);
  88084. /** @hidden */
  88085. dispose(): void;
  88086. /** @hidden */
  88087. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88088. private _loadClearCoatPropertiesAsync;
  88089. }
  88090. }
  88091. declare module BABYLON.GLTF2.Loader.Extensions {
  88092. /**
  88093. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  88094. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  88095. * !!! Experimental Extension Subject to Changes !!!
  88096. */
  88097. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  88098. /**
  88099. * The name of this extension.
  88100. */
  88101. readonly name: string;
  88102. /**
  88103. * Defines whether this extension is enabled.
  88104. */
  88105. enabled: boolean;
  88106. /**
  88107. * Defines a number that determines the order the extensions are applied.
  88108. */
  88109. order: number;
  88110. private _loader;
  88111. /** @hidden */
  88112. constructor(loader: GLTFLoader);
  88113. /** @hidden */
  88114. dispose(): void;
  88115. /** @hidden */
  88116. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88117. private _loadSheenPropertiesAsync;
  88118. }
  88119. }
  88120. declare module BABYLON.GLTF2.Loader.Extensions {
  88121. /**
  88122. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  88123. * !!! Experimental Extension Subject to Changes !!!
  88124. */
  88125. export class KHR_materials_specular implements IGLTFLoaderExtension {
  88126. /**
  88127. * The name of this extension.
  88128. */
  88129. readonly name: string;
  88130. /**
  88131. * Defines whether this extension is enabled.
  88132. */
  88133. enabled: boolean;
  88134. /**
  88135. * Defines a number that determines the order the extensions are applied.
  88136. */
  88137. order: number;
  88138. private _loader;
  88139. /** @hidden */
  88140. constructor(loader: GLTFLoader);
  88141. /** @hidden */
  88142. dispose(): void;
  88143. /** @hidden */
  88144. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88145. private _loadSpecularPropertiesAsync;
  88146. }
  88147. }
  88148. declare module BABYLON.GLTF2.Loader.Extensions {
  88149. /**
  88150. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  88151. * !!! Experimental Extension Subject to Changes !!!
  88152. */
  88153. export class KHR_materials_ior implements IGLTFLoaderExtension {
  88154. /**
  88155. * Default ior Value from the spec.
  88156. */
  88157. private static readonly _DEFAULT_IOR;
  88158. /**
  88159. * The name of this extension.
  88160. */
  88161. readonly name: string;
  88162. /**
  88163. * Defines whether this extension is enabled.
  88164. */
  88165. enabled: boolean;
  88166. /**
  88167. * Defines a number that determines the order the extensions are applied.
  88168. */
  88169. order: number;
  88170. private _loader;
  88171. /** @hidden */
  88172. constructor(loader: GLTFLoader);
  88173. /** @hidden */
  88174. dispose(): void;
  88175. /** @hidden */
  88176. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88177. private _loadIorPropertiesAsync;
  88178. }
  88179. }
  88180. declare module BABYLON.GLTF2.Loader.Extensions {
  88181. /**
  88182. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  88183. */
  88184. export class KHR_materials_variants implements IGLTFLoaderExtension {
  88185. /**
  88186. * The name of this extension.
  88187. */
  88188. readonly name: string;
  88189. /**
  88190. * Defines whether this extension is enabled.
  88191. */
  88192. enabled: boolean;
  88193. private _loader;
  88194. private _variants?;
  88195. /** @hidden */
  88196. constructor(loader: GLTFLoader);
  88197. /** @hidden */
  88198. dispose(): void;
  88199. /**
  88200. * Gets the list of available variant names for this asset.
  88201. * @param rootMesh The glTF root mesh
  88202. * @returns the list of all the variant names for this model
  88203. */
  88204. static GetAvailableVariants(rootMesh: Mesh): string[];
  88205. /**
  88206. * Gets the list of available variant names for this asset.
  88207. * @param rootMesh The glTF root mesh
  88208. * @returns the list of all the variant names for this model
  88209. */
  88210. getAvailableVariants(rootMesh: Mesh): string[];
  88211. /**
  88212. * Select a variant given a variant name or a list of variant names.
  88213. * @param rootMesh The glTF root mesh
  88214. * @param variantName The variant name(s) to select.
  88215. */
  88216. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88217. /**
  88218. * Select a variant given a variant name or a list of variant names.
  88219. * @param rootMesh The glTF root mesh
  88220. * @param variantName The variant name(s) to select.
  88221. */
  88222. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88223. /**
  88224. * Reset back to the original before selecting a variant.
  88225. * @param rootMesh The glTF root mesh
  88226. */
  88227. static Reset(rootMesh: Mesh): void;
  88228. /**
  88229. * Reset back to the original before selecting a variant.
  88230. * @param rootMesh The glTF root mesh
  88231. */
  88232. reset(rootMesh: Mesh): void;
  88233. /**
  88234. * Gets the last selected variant name(s) or null if original.
  88235. * @param rootMesh The glTF root mesh
  88236. * @returns The selected variant name(s).
  88237. */
  88238. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88239. /**
  88240. * Gets the last selected variant name(s) or null if original.
  88241. * @param rootMesh The glTF root mesh
  88242. * @returns The selected variant name(s).
  88243. */
  88244. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88245. private static _GetExtensionMetadata;
  88246. /** @hidden */
  88247. onLoading(): void;
  88248. /** @hidden */
  88249. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88250. }
  88251. }
  88252. declare module BABYLON.GLTF2.Loader.Extensions {
  88253. /**
  88254. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  88255. */
  88256. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  88257. /**
  88258. * The name of this extension.
  88259. */
  88260. readonly name: string;
  88261. /**
  88262. * Defines whether this extension is enabled.
  88263. */
  88264. enabled: boolean;
  88265. /**
  88266. * Defines a number that determines the order the extensions are applied.
  88267. */
  88268. order: number;
  88269. private _loader;
  88270. /** @hidden */
  88271. constructor(loader: GLTFLoader);
  88272. /** @hidden */
  88273. dispose(): void;
  88274. /** @hidden */
  88275. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88276. private _loadTransparentPropertiesAsync;
  88277. }
  88278. }
  88279. declare module BABYLON.GLTF2.Loader.Extensions {
  88280. /**
  88281. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  88282. * !!! Experimental Extension Subject to Changes !!!
  88283. */
  88284. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  88285. /**
  88286. * The name of this extension.
  88287. */
  88288. readonly name: string;
  88289. /**
  88290. * Defines whether this extension is enabled.
  88291. */
  88292. enabled: boolean;
  88293. /**
  88294. * Defines a number that determines the order the extensions are applied.
  88295. */
  88296. order: number;
  88297. private _loader;
  88298. /** @hidden */
  88299. constructor(loader: GLTFLoader);
  88300. /** @hidden */
  88301. dispose(): void;
  88302. /** @hidden */
  88303. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88304. private _loadTranslucentPropertiesAsync;
  88305. }
  88306. }
  88307. declare module BABYLON.GLTF2.Loader.Extensions {
  88308. /**
  88309. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  88310. */
  88311. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  88312. /**
  88313. * The name of this extension.
  88314. */
  88315. readonly name: string;
  88316. /**
  88317. * Defines whether this extension is enabled.
  88318. */
  88319. enabled: boolean;
  88320. /** @hidden */
  88321. constructor(loader: GLTFLoader);
  88322. /** @hidden */
  88323. dispose(): void;
  88324. }
  88325. }
  88326. declare module BABYLON.GLTF2.Loader.Extensions {
  88327. /**
  88328. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  88329. * !!! Experimental Extension Subject to Changes !!!
  88330. */
  88331. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  88332. /** The name of this extension. */
  88333. readonly name: string;
  88334. /** Defines whether this extension is enabled. */
  88335. enabled: boolean;
  88336. private _loader;
  88337. /** @hidden */
  88338. constructor(loader: GLTFLoader);
  88339. /** @hidden */
  88340. dispose(): void;
  88341. /** @hidden */
  88342. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88343. }
  88344. }
  88345. declare module BABYLON.GLTF2.Loader.Extensions {
  88346. /**
  88347. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  88348. */
  88349. export class KHR_texture_transform 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. private _loader;
  88359. /** @hidden */
  88360. constructor(loader: GLTFLoader);
  88361. /** @hidden */
  88362. dispose(): void;
  88363. /** @hidden */
  88364. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88365. }
  88366. }
  88367. declare module BABYLON.GLTF2.Loader.Extensions {
  88368. /**
  88369. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  88370. */
  88371. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  88372. /**
  88373. * The name of this extension.
  88374. */
  88375. readonly name: string;
  88376. /**
  88377. * Defines whether this extension is enabled.
  88378. */
  88379. enabled: boolean;
  88380. private _loader;
  88381. private _clips;
  88382. private _emitters;
  88383. /** @hidden */
  88384. constructor(loader: GLTFLoader);
  88385. /** @hidden */
  88386. dispose(): void;
  88387. /** @hidden */
  88388. onLoading(): void;
  88389. /** @hidden */
  88390. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88391. /** @hidden */
  88392. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88393. /** @hidden */
  88394. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88395. private _loadClipAsync;
  88396. private _loadEmitterAsync;
  88397. private _getEventAction;
  88398. private _loadAnimationEventAsync;
  88399. }
  88400. }
  88401. declare module BABYLON.GLTF2.Loader.Extensions {
  88402. /**
  88403. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  88404. */
  88405. export class MSFT_lod implements IGLTFLoaderExtension {
  88406. /**
  88407. * The name of this extension.
  88408. */
  88409. readonly name: string;
  88410. /**
  88411. * Defines whether this extension is enabled.
  88412. */
  88413. enabled: boolean;
  88414. /**
  88415. * Defines a number that determines the order the extensions are applied.
  88416. */
  88417. order: number;
  88418. /**
  88419. * Maximum number of LODs to load, starting from the lowest LOD.
  88420. */
  88421. maxLODsToLoad: number;
  88422. /**
  88423. * Observable raised when all node LODs of one level are loaded.
  88424. * The event data is the index of the loaded LOD starting from zero.
  88425. * Dispose the loader to cancel the loading of the next level of LODs.
  88426. */
  88427. onNodeLODsLoadedObservable: Observable<number>;
  88428. /**
  88429. * Observable raised when all material LODs of one level are loaded.
  88430. * The event data is the index of the loaded LOD starting from zero.
  88431. * Dispose the loader to cancel the loading of the next level of LODs.
  88432. */
  88433. onMaterialLODsLoadedObservable: Observable<number>;
  88434. private _loader;
  88435. private _bufferLODs;
  88436. private _nodeIndexLOD;
  88437. private _nodeSignalLODs;
  88438. private _nodePromiseLODs;
  88439. private _nodeBufferLODs;
  88440. private _materialIndexLOD;
  88441. private _materialSignalLODs;
  88442. private _materialPromiseLODs;
  88443. private _materialBufferLODs;
  88444. /** @hidden */
  88445. constructor(loader: GLTFLoader);
  88446. /** @hidden */
  88447. dispose(): void;
  88448. /** @hidden */
  88449. onReady(): void;
  88450. /** @hidden */
  88451. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88452. /** @hidden */
  88453. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88454. /** @hidden */
  88455. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88456. /** @hidden */
  88457. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88458. /** @hidden */
  88459. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88460. private _loadBufferLOD;
  88461. /**
  88462. * Gets an array of LOD properties from lowest to highest.
  88463. */
  88464. private _getLODs;
  88465. private _disposeTransformNode;
  88466. private _disposeMaterials;
  88467. }
  88468. }
  88469. declare module BABYLON.GLTF2.Loader.Extensions {
  88470. /** @hidden */
  88471. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  88472. readonly name: string;
  88473. enabled: boolean;
  88474. private _loader;
  88475. constructor(loader: GLTFLoader);
  88476. dispose(): void;
  88477. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88478. }
  88479. }
  88480. declare module BABYLON.GLTF2.Loader.Extensions {
  88481. /** @hidden */
  88482. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  88483. readonly name: string;
  88484. enabled: boolean;
  88485. private _loader;
  88486. constructor(loader: GLTFLoader);
  88487. dispose(): void;
  88488. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88489. }
  88490. }
  88491. declare module BABYLON.GLTF2.Loader.Extensions {
  88492. /**
  88493. * Store glTF extras (if present) in BJS objects' metadata
  88494. */
  88495. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  88496. /**
  88497. * The name of this extension.
  88498. */
  88499. readonly name: string;
  88500. /**
  88501. * Defines whether this extension is enabled.
  88502. */
  88503. enabled: boolean;
  88504. private _loader;
  88505. private _assignExtras;
  88506. /** @hidden */
  88507. constructor(loader: GLTFLoader);
  88508. /** @hidden */
  88509. dispose(): void;
  88510. /** @hidden */
  88511. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88512. /** @hidden */
  88513. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88514. /** @hidden */
  88515. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88516. }
  88517. }
  88518. declare module BABYLON {
  88519. /**
  88520. * Class reading and parsing the MTL file bundled with the obj file.
  88521. */
  88522. export class MTLFileLoader {
  88523. /**
  88524. * Invert Y-Axis of referenced textures on load
  88525. */
  88526. static INVERT_TEXTURE_Y: boolean;
  88527. /**
  88528. * All material loaded from the mtl will be set here
  88529. */
  88530. materials: StandardMaterial[];
  88531. /**
  88532. * This function will read the mtl file and create each material described inside
  88533. * This function could be improve by adding :
  88534. * -some component missing (Ni, Tf...)
  88535. * -including the specific options available
  88536. *
  88537. * @param scene defines the scene the material will be created in
  88538. * @param data defines the mtl data to parse
  88539. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  88540. * @param forAssetContainer defines if the material should be registered in the scene
  88541. */
  88542. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  88543. /**
  88544. * Gets the texture for the material.
  88545. *
  88546. * If the material is imported from input file,
  88547. * We sanitize the url to ensure it takes the textre from aside the material.
  88548. *
  88549. * @param rootUrl The root url to load from
  88550. * @param value The value stored in the mtl
  88551. * @return The Texture
  88552. */
  88553. private static _getTexture;
  88554. }
  88555. }
  88556. declare module BABYLON {
  88557. /**
  88558. * Options for loading OBJ/MTL files
  88559. */
  88560. type MeshLoadOptions = {
  88561. /**
  88562. * Defines if UVs are optimized by default during load.
  88563. */
  88564. OptimizeWithUV: boolean;
  88565. /**
  88566. * Defines custom scaling of UV coordinates of loaded meshes.
  88567. */
  88568. UVScaling: Vector2;
  88569. /**
  88570. * Invert model on y-axis (does a model scaling inversion)
  88571. */
  88572. InvertY: boolean;
  88573. /**
  88574. * Invert Y-Axis of referenced textures on load
  88575. */
  88576. InvertTextureY: boolean;
  88577. /**
  88578. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88579. */
  88580. ImportVertexColors: boolean;
  88581. /**
  88582. * Compute the normals for the model, even if normals are present in the file.
  88583. */
  88584. ComputeNormals: boolean;
  88585. /**
  88586. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88587. */
  88588. SkipMaterials: boolean;
  88589. /**
  88590. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88591. */
  88592. MaterialLoadingFailsSilently: boolean;
  88593. };
  88594. /**
  88595. * OBJ file type loader.
  88596. * This is a babylon scene loader plugin.
  88597. */
  88598. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  88599. /**
  88600. * Defines if UVs are optimized by default during load.
  88601. */
  88602. static OPTIMIZE_WITH_UV: boolean;
  88603. /**
  88604. * Invert model on y-axis (does a model scaling inversion)
  88605. */
  88606. static INVERT_Y: boolean;
  88607. /**
  88608. * Invert Y-Axis of referenced textures on load
  88609. */
  88610. static get INVERT_TEXTURE_Y(): boolean;
  88611. static set INVERT_TEXTURE_Y(value: boolean);
  88612. /**
  88613. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88614. */
  88615. static IMPORT_VERTEX_COLORS: boolean;
  88616. /**
  88617. * Compute the normals for the model, even if normals are present in the file.
  88618. */
  88619. static COMPUTE_NORMALS: boolean;
  88620. /**
  88621. * Defines custom scaling of UV coordinates of loaded meshes.
  88622. */
  88623. static UV_SCALING: Vector2;
  88624. /**
  88625. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88626. */
  88627. static SKIP_MATERIALS: boolean;
  88628. /**
  88629. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88630. *
  88631. * Defaults to true for backwards compatibility.
  88632. */
  88633. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  88634. /**
  88635. * Defines the name of the plugin.
  88636. */
  88637. name: string;
  88638. /**
  88639. * Defines the extension the plugin is able to load.
  88640. */
  88641. extensions: string;
  88642. /** @hidden */
  88643. obj: RegExp;
  88644. /** @hidden */
  88645. group: RegExp;
  88646. /** @hidden */
  88647. mtllib: RegExp;
  88648. /** @hidden */
  88649. usemtl: RegExp;
  88650. /** @hidden */
  88651. smooth: RegExp;
  88652. /** @hidden */
  88653. vertexPattern: RegExp;
  88654. /** @hidden */
  88655. normalPattern: RegExp;
  88656. /** @hidden */
  88657. uvPattern: RegExp;
  88658. /** @hidden */
  88659. facePattern1: RegExp;
  88660. /** @hidden */
  88661. facePattern2: RegExp;
  88662. /** @hidden */
  88663. facePattern3: RegExp;
  88664. /** @hidden */
  88665. facePattern4: RegExp;
  88666. /** @hidden */
  88667. facePattern5: RegExp;
  88668. private _forAssetContainer;
  88669. private _meshLoadOptions;
  88670. /**
  88671. * Creates loader for .OBJ files
  88672. *
  88673. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  88674. */
  88675. constructor(meshLoadOptions?: MeshLoadOptions);
  88676. private static get currentMeshLoadOptions();
  88677. /**
  88678. * Calls synchronously the MTL file attached to this obj.
  88679. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  88680. * Without this function materials are not displayed in the first frame (but displayed after).
  88681. * In consequence it is impossible to get material information in your HTML file
  88682. *
  88683. * @param url The URL of the MTL file
  88684. * @param rootUrl
  88685. * @param onSuccess Callback function to be called when the MTL file is loaded
  88686. * @private
  88687. */
  88688. private _loadMTL;
  88689. /**
  88690. * Instantiates a OBJ file loader plugin.
  88691. * @returns the created plugin
  88692. */
  88693. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  88694. /**
  88695. * If the data string can be loaded directly.
  88696. *
  88697. * @param data string containing the file data
  88698. * @returns if the data can be loaded directly
  88699. */
  88700. canDirectLoad(data: string): boolean;
  88701. /**
  88702. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  88703. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  88704. * @param scene the scene the meshes should be added to
  88705. * @param data the OBJ data to load
  88706. * @param rootUrl root url to load from
  88707. * @param onProgress event that fires when loading progress has occured
  88708. * @param fileName Defines the name of the file to load
  88709. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  88710. */
  88711. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88712. /**
  88713. * Imports all objects from the loaded OBJ data and adds them to the scene
  88714. * @param scene the scene the objects should be added to
  88715. * @param data the OBJ data to load
  88716. * @param rootUrl root url to load from
  88717. * @param onProgress event that fires when loading progress has occured
  88718. * @param fileName Defines the name of the file to load
  88719. * @returns a promise which completes when objects have been loaded to the scene
  88720. */
  88721. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88722. /**
  88723. * Load into an asset container.
  88724. * @param scene The scene to load into
  88725. * @param data The data to import
  88726. * @param rootUrl The root url for scene and resources
  88727. * @param onProgress The callback when the load progresses
  88728. * @param fileName Defines the name of the file to load
  88729. * @returns The loaded asset container
  88730. */
  88731. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  88732. /**
  88733. * Read the OBJ file and create an Array of meshes.
  88734. * Each mesh contains all information given by the OBJ and the MTL file.
  88735. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  88736. *
  88737. * @param meshesNames
  88738. * @param scene Scene The scene where are displayed the data
  88739. * @param data String The content of the obj file
  88740. * @param rootUrl String The path to the folder
  88741. * @returns Array<AbstractMesh>
  88742. * @private
  88743. */
  88744. private _parseSolid;
  88745. }
  88746. }
  88747. declare module BABYLON {
  88748. /**
  88749. * STL file type loader.
  88750. * This is a babylon scene loader plugin.
  88751. */
  88752. export class STLFileLoader implements ISceneLoaderPlugin {
  88753. /** @hidden */
  88754. solidPattern: RegExp;
  88755. /** @hidden */
  88756. facetsPattern: RegExp;
  88757. /** @hidden */
  88758. normalPattern: RegExp;
  88759. /** @hidden */
  88760. vertexPattern: RegExp;
  88761. /**
  88762. * Defines the name of the plugin.
  88763. */
  88764. name: string;
  88765. /**
  88766. * Defines the extensions the stl loader is able to load.
  88767. * force data to come in as an ArrayBuffer
  88768. * we'll convert to string if it looks like it's an ASCII .stl
  88769. */
  88770. extensions: ISceneLoaderPluginExtensions;
  88771. /**
  88772. * Import meshes into a scene.
  88773. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  88774. * @param scene The scene to import into
  88775. * @param data The data to import
  88776. * @param rootUrl The root url for scene and resources
  88777. * @param meshes The meshes array to import into
  88778. * @param particleSystems The particle systems array to import into
  88779. * @param skeletons The skeletons array to import into
  88780. * @param onError The callback when import fails
  88781. * @returns True if successful or false otherwise
  88782. */
  88783. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  88784. /**
  88785. * Load into a scene.
  88786. * @param scene The scene to load into
  88787. * @param data The data to import
  88788. * @param rootUrl The root url for scene and resources
  88789. * @param onError The callback when import fails
  88790. * @returns true if successful or false otherwise
  88791. */
  88792. load(scene: Scene, data: any, rootUrl: string): boolean;
  88793. /**
  88794. * Load into an asset container.
  88795. * @param scene The scene to load into
  88796. * @param data The data to import
  88797. * @param rootUrl The root url for scene and resources
  88798. * @param onError The callback when import fails
  88799. * @returns The loaded asset container
  88800. */
  88801. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  88802. private _isBinary;
  88803. private _parseBinary;
  88804. private _parseASCII;
  88805. }
  88806. }
  88807. declare module BABYLON {
  88808. /**
  88809. * Class for generating OBJ data from a Babylon scene.
  88810. */
  88811. export class OBJExport {
  88812. /**
  88813. * Exports the geometry of a Mesh array in .OBJ file format (text)
  88814. * @param mesh defines the list of meshes to serialize
  88815. * @param materials defines if materials should be exported
  88816. * @param matlibname defines the name of the associated mtl file
  88817. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  88818. * @returns the OBJ content
  88819. */
  88820. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  88821. /**
  88822. * Exports the material(s) of a mesh in .MTL file format (text)
  88823. * @param mesh defines the mesh to extract the material from
  88824. * @returns the mtl content
  88825. */
  88826. static MTL(mesh: Mesh): string;
  88827. }
  88828. }
  88829. declare module BABYLON {
  88830. /** @hidden */
  88831. export var __IGLTFExporterExtension: number;
  88832. /**
  88833. * Interface for extending the exporter
  88834. * @hidden
  88835. */
  88836. export interface IGLTFExporterExtension {
  88837. /**
  88838. * The name of this extension
  88839. */
  88840. readonly name: string;
  88841. /**
  88842. * Defines whether this extension is enabled
  88843. */
  88844. enabled: boolean;
  88845. /**
  88846. * Defines whether this extension is required
  88847. */
  88848. required: boolean;
  88849. }
  88850. }
  88851. declare module BABYLON.GLTF2.Exporter {
  88852. /** @hidden */
  88853. export var __IGLTFExporterExtensionV2: number;
  88854. /**
  88855. * Interface for a glTF exporter extension
  88856. * @hidden
  88857. */
  88858. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  88859. /**
  88860. * Define this method to modify the default behavior before exporting a texture
  88861. * @param context The context when loading the asset
  88862. * @param babylonTexture The Babylon.js texture
  88863. * @param mimeType The mime-type of the generated image
  88864. * @returns A promise that resolves with the exported texture
  88865. */
  88866. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  88867. /**
  88868. * Define this method to get notified when a texture info is created
  88869. * @param context The context when loading the asset
  88870. * @param textureInfo The glTF texture info
  88871. * @param babylonTexture The Babylon.js texture
  88872. */
  88873. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  88874. /**
  88875. * Define this method to modify the default behavior when exporting texture info
  88876. * @param context The context when loading the asset
  88877. * @param meshPrimitive glTF mesh primitive
  88878. * @param babylonSubMesh Babylon submesh
  88879. * @param binaryWriter glTF serializer binary writer instance
  88880. * @returns nullable IMeshPrimitive promise
  88881. */
  88882. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  88883. /**
  88884. * Define this method to modify the default behavior when exporting a node
  88885. * @param context The context when exporting the node
  88886. * @param node glTF node
  88887. * @param babylonNode BabylonJS node
  88888. * @returns nullable INode promise
  88889. */
  88890. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  88891. [key: number]: number;
  88892. }): Promise<Nullable<INode>>;
  88893. /**
  88894. * Define this method to modify the default behavior when exporting a material
  88895. * @param material glTF material
  88896. * @param babylonMaterial BabylonJS material
  88897. * @returns nullable IMaterial promise
  88898. */
  88899. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  88900. /**
  88901. * Define this method to return additional textures to export from a material
  88902. * @param material glTF material
  88903. * @param babylonMaterial BabylonJS material
  88904. * @returns List of textures
  88905. */
  88906. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  88907. /** Gets a boolean indicating that this extension was used */
  88908. wasUsed: boolean;
  88909. /** Gets a boolean indicating that this extension is required for the file to work */
  88910. required: boolean;
  88911. /**
  88912. * Called after the exporter state changes to EXPORTING
  88913. */
  88914. onExporting?(): void;
  88915. }
  88916. }
  88917. declare module BABYLON.GLTF2.Exporter {
  88918. /**
  88919. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  88920. * @hidden
  88921. */
  88922. export class _GLTFMaterialExporter {
  88923. /**
  88924. * Represents the dielectric specular values for R, G and B
  88925. */
  88926. private static readonly _DielectricSpecular;
  88927. /**
  88928. * Allows the maximum specular power to be defined for material calculations
  88929. */
  88930. private static readonly _MaxSpecularPower;
  88931. /**
  88932. * Mapping to store textures
  88933. */
  88934. private _textureMap;
  88935. /**
  88936. * Numeric tolerance value
  88937. */
  88938. private static readonly _Epsilon;
  88939. /**
  88940. * Reference to the glTF Exporter
  88941. */
  88942. private _exporter;
  88943. constructor(exporter: _Exporter);
  88944. /**
  88945. * Specifies if two colors are approximately equal in value
  88946. * @param color1 first color to compare to
  88947. * @param color2 second color to compare to
  88948. * @param epsilon threshold value
  88949. */
  88950. private static FuzzyEquals;
  88951. /**
  88952. * Gets the materials from a Babylon scene and converts them to glTF materials
  88953. * @param scene babylonjs scene
  88954. * @param mimeType texture mime type
  88955. * @param images array of images
  88956. * @param textures array of textures
  88957. * @param materials array of materials
  88958. * @param imageData mapping of texture names to base64 textures
  88959. * @param hasTextureCoords specifies if texture coordinates are present on the material
  88960. */
  88961. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  88962. /**
  88963. * Makes a copy of the glTF material without the texture parameters
  88964. * @param originalMaterial original glTF material
  88965. * @returns glTF material without texture parameters
  88966. */
  88967. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  88968. /**
  88969. * Specifies if the material has any texture parameters present
  88970. * @param material glTF Material
  88971. * @returns boolean specifying if texture parameters are present
  88972. */
  88973. _hasTexturesPresent(material: IMaterial): boolean;
  88974. /**
  88975. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  88976. * @param babylonStandardMaterial
  88977. * @returns glTF Metallic Roughness Material representation
  88978. */
  88979. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  88980. /**
  88981. * Computes the metallic factor
  88982. * @param diffuse diffused value
  88983. * @param specular specular value
  88984. * @param oneMinusSpecularStrength one minus the specular strength
  88985. * @returns metallic value
  88986. */
  88987. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  88988. /**
  88989. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  88990. * @param glTFMaterial glTF material
  88991. * @param babylonMaterial Babylon material
  88992. */
  88993. private static _SetAlphaMode;
  88994. /**
  88995. * Converts a Babylon Standard Material to a glTF Material
  88996. * @param babylonStandardMaterial BJS Standard Material
  88997. * @param mimeType mime type to use for the textures
  88998. * @param images array of glTF image interfaces
  88999. * @param textures array of glTF texture interfaces
  89000. * @param materials array of glTF material interfaces
  89001. * @param imageData map of image file name to data
  89002. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89003. */
  89004. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89005. private _finishMaterial;
  89006. /**
  89007. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  89008. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  89009. * @param mimeType mime type to use for the textures
  89010. * @param images array of glTF image interfaces
  89011. * @param textures array of glTF texture interfaces
  89012. * @param materials array of glTF material interfaces
  89013. * @param imageData map of image file name to data
  89014. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89015. */
  89016. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89017. /**
  89018. * Converts an image typed array buffer to a base64 image
  89019. * @param buffer typed array buffer
  89020. * @param width width of the image
  89021. * @param height height of the image
  89022. * @param mimeType mimetype of the image
  89023. * @returns base64 image string
  89024. */
  89025. private _createBase64FromCanvasAsync;
  89026. /**
  89027. * Generates a white texture based on the specified width and height
  89028. * @param width width of the texture in pixels
  89029. * @param height height of the texture in pixels
  89030. * @param scene babylonjs scene
  89031. * @returns white texture
  89032. */
  89033. private _createWhiteTexture;
  89034. /**
  89035. * 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
  89036. * @param texture1 first texture to resize
  89037. * @param texture2 second texture to resize
  89038. * @param scene babylonjs scene
  89039. * @returns resized textures or null
  89040. */
  89041. private _resizeTexturesToSameDimensions;
  89042. /**
  89043. * Converts an array of pixels to a Float32Array
  89044. * Throws an error if the pixel format is not supported
  89045. * @param pixels - array buffer containing pixel values
  89046. * @returns Float32 of pixels
  89047. */
  89048. private _convertPixelArrayToFloat32;
  89049. /**
  89050. * Convert Specular Glossiness Textures to Metallic Roughness
  89051. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  89052. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  89053. * @param diffuseTexture texture used to store diffuse information
  89054. * @param specularGlossinessTexture texture used to store specular and glossiness information
  89055. * @param factors specular glossiness material factors
  89056. * @param mimeType the mime type to use for the texture
  89057. * @returns pbr metallic roughness interface or null
  89058. */
  89059. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  89060. /**
  89061. * Converts specular glossiness material properties to metallic roughness
  89062. * @param specularGlossiness interface with specular glossiness material properties
  89063. * @returns interface with metallic roughness material properties
  89064. */
  89065. private _convertSpecularGlossinessToMetallicRoughness;
  89066. /**
  89067. * Calculates the surface reflectance, independent of lighting conditions
  89068. * @param color Color source to calculate brightness from
  89069. * @returns number representing the perceived brightness, or zero if color is undefined
  89070. */
  89071. private _getPerceivedBrightness;
  89072. /**
  89073. * Returns the maximum color component value
  89074. * @param color
  89075. * @returns maximum color component value, or zero if color is null or undefined
  89076. */
  89077. private _getMaxComponent;
  89078. /**
  89079. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  89080. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89081. * @param mimeType mime type to use for the textures
  89082. * @param images array of glTF image interfaces
  89083. * @param textures array of glTF texture interfaces
  89084. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89085. * @param imageData map of image file name to data
  89086. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89087. * @returns glTF PBR Metallic Roughness factors
  89088. */
  89089. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  89090. private _getGLTFTextureSampler;
  89091. private _getGLTFTextureWrapMode;
  89092. private _getGLTFTextureWrapModesSampler;
  89093. /**
  89094. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  89095. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89096. * @param mimeType mime type to use for the textures
  89097. * @param images array of glTF image interfaces
  89098. * @param textures array of glTF texture interfaces
  89099. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89100. * @param imageData map of image file name to data
  89101. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89102. * @returns glTF PBR Metallic Roughness factors
  89103. */
  89104. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  89105. /**
  89106. * Converts a Babylon PBR Base Material to a glTF Material
  89107. * @param babylonPBRMaterial BJS PBR Base Material
  89108. * @param mimeType mime type to use for the textures
  89109. * @param images array of glTF image interfaces
  89110. * @param textures array of glTF texture interfaces
  89111. * @param materials array of glTF material interfaces
  89112. * @param imageData map of image file name to data
  89113. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89114. */
  89115. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89116. private setMetallicRoughnessPbrMaterial;
  89117. private getPixelsFromTexture;
  89118. /**
  89119. * Extracts a texture from a Babylon texture into file data and glTF data
  89120. * @param babylonTexture Babylon texture to extract
  89121. * @param mimeType Mime Type of the babylonTexture
  89122. * @return glTF texture info, or null if the texture format is not supported
  89123. */
  89124. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89125. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89126. /**
  89127. * Builds a texture from base64 string
  89128. * @param base64Texture base64 texture string
  89129. * @param baseTextureName Name to use for the texture
  89130. * @param mimeType image mime type for the texture
  89131. * @param images array of images
  89132. * @param textures array of textures
  89133. * @param imageData map of image data
  89134. * @returns glTF texture info, or null if the texture format is not supported
  89135. */
  89136. private _getTextureInfoFromBase64;
  89137. }
  89138. }
  89139. declare module BABYLON {
  89140. /**
  89141. * Class for holding and downloading glTF file data
  89142. */
  89143. export class GLTFData {
  89144. /**
  89145. * Object which contains the file name as the key and its data as the value
  89146. */
  89147. glTFFiles: {
  89148. [fileName: string]: string | Blob;
  89149. };
  89150. /**
  89151. * Initializes the glTF file object
  89152. */
  89153. constructor();
  89154. /**
  89155. * Downloads the glTF data as files based on their names and data
  89156. */
  89157. downloadFiles(): void;
  89158. }
  89159. }
  89160. declare module BABYLON {
  89161. /**
  89162. * Holds a collection of exporter options and parameters
  89163. */
  89164. export interface IExportOptions {
  89165. /**
  89166. * Function which indicates whether a babylon node should be exported or not
  89167. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  89168. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  89169. */
  89170. shouldExportNode?(node: Node): boolean;
  89171. /**
  89172. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  89173. * @param metadata source metadata to read from
  89174. * @returns the data to store to glTF node extras
  89175. */
  89176. metadataSelector?(metadata: any): any;
  89177. /**
  89178. * The sample rate to bake animation curves
  89179. */
  89180. animationSampleRate?: number;
  89181. /**
  89182. * Begin serialization without waiting for the scene to be ready
  89183. */
  89184. exportWithoutWaitingForScene?: boolean;
  89185. /**
  89186. * Indicates if coordinate system swapping root nodes should be included in export
  89187. */
  89188. includeCoordinateSystemConversionNodes?: boolean;
  89189. }
  89190. /**
  89191. * Class for generating glTF data from a Babylon scene.
  89192. */
  89193. export class GLTF2Export {
  89194. /**
  89195. * Exports the geometry of the scene to .gltf file format asynchronously
  89196. * @param scene Babylon scene with scene hierarchy information
  89197. * @param filePrefix File prefix to use when generating the glTF file
  89198. * @param options Exporter options
  89199. * @returns Returns an object with a .gltf file and associates texture names
  89200. * as keys and their data and paths as values
  89201. */
  89202. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89203. private static _PreExportAsync;
  89204. private static _PostExportAsync;
  89205. /**
  89206. * Exports the geometry of the scene to .glb file format asychronously
  89207. * @param scene Babylon scene with scene hierarchy information
  89208. * @param filePrefix File prefix to use when generating glb file
  89209. * @param options Exporter options
  89210. * @returns Returns an object with a .glb filename as key and data as value
  89211. */
  89212. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89213. }
  89214. }
  89215. declare module BABYLON.GLTF2.Exporter {
  89216. /**
  89217. * @hidden
  89218. */
  89219. export class _GLTFUtilities {
  89220. /**
  89221. * Creates a buffer view based on the supplied arguments
  89222. * @param bufferIndex index value of the specified buffer
  89223. * @param byteOffset byte offset value
  89224. * @param byteLength byte length of the bufferView
  89225. * @param byteStride byte distance between conequential elements
  89226. * @param name name of the buffer view
  89227. * @returns bufferView for glTF
  89228. */
  89229. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  89230. /**
  89231. * Creates an accessor based on the supplied arguments
  89232. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  89233. * @param name The name of the accessor
  89234. * @param type The type of the accessor
  89235. * @param componentType The datatype of components in the attribute
  89236. * @param count The number of attributes referenced by this accessor
  89237. * @param byteOffset The offset relative to the start of the bufferView in bytes
  89238. * @param min Minimum value of each component in this attribute
  89239. * @param max Maximum value of each component in this attribute
  89240. * @returns accessor for glTF
  89241. */
  89242. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  89243. /**
  89244. * Calculates the minimum and maximum values of an array of position floats
  89245. * @param positions Positions array of a mesh
  89246. * @param vertexStart Starting vertex offset to calculate min and max values
  89247. * @param vertexCount Number of vertices to check for min and max values
  89248. * @returns min number array and max number array
  89249. */
  89250. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  89251. min: number[];
  89252. max: number[];
  89253. };
  89254. /**
  89255. * Converts a new right-handed Vector3
  89256. * @param vector vector3 array
  89257. * @returns right-handed Vector3
  89258. */
  89259. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  89260. /**
  89261. * Converts a Vector3 to right-handed
  89262. * @param vector Vector3 to convert to right-handed
  89263. */
  89264. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  89265. /**
  89266. * Converts a three element number array to right-handed
  89267. * @param vector number array to convert to right-handed
  89268. */
  89269. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  89270. /**
  89271. * Converts a new right-handed Vector3
  89272. * @param vector vector3 array
  89273. * @returns right-handed Vector3
  89274. */
  89275. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  89276. /**
  89277. * Converts a Vector3 to right-handed
  89278. * @param vector Vector3 to convert to right-handed
  89279. */
  89280. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  89281. /**
  89282. * Converts a three element number array to right-handed
  89283. * @param vector number array to convert to right-handed
  89284. */
  89285. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  89286. /**
  89287. * Converts a Vector4 to right-handed
  89288. * @param vector Vector4 to convert to right-handed
  89289. */
  89290. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  89291. /**
  89292. * Converts a Vector4 to right-handed
  89293. * @param vector Vector4 to convert to right-handed
  89294. */
  89295. static _GetRightHandedArray4FromRef(vector: number[]): void;
  89296. /**
  89297. * Converts a Quaternion to right-handed
  89298. * @param quaternion Source quaternion to convert to right-handed
  89299. */
  89300. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  89301. /**
  89302. * Converts a Quaternion to right-handed
  89303. * @param quaternion Source quaternion to convert to right-handed
  89304. */
  89305. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  89306. static _NormalizeTangentFromRef(tangent: Vector4): void;
  89307. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  89308. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  89309. }
  89310. }
  89311. declare module BABYLON.GLTF2.Exporter {
  89312. /**
  89313. * Converts Babylon Scene into glTF 2.0.
  89314. * @hidden
  89315. */
  89316. export class _Exporter {
  89317. /**
  89318. * Stores the glTF to export
  89319. */
  89320. _glTF: IGLTF;
  89321. /**
  89322. * Stores all generated buffer views, which represents views into the main glTF buffer data
  89323. */
  89324. _bufferViews: IBufferView[];
  89325. /**
  89326. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  89327. */
  89328. _accessors: IAccessor[];
  89329. /**
  89330. * Stores all the generated nodes, which contains transform and/or mesh information per node
  89331. */
  89332. _nodes: INode[];
  89333. /**
  89334. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  89335. */
  89336. private _scenes;
  89337. /**
  89338. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  89339. */
  89340. private _meshes;
  89341. /**
  89342. * Stores all the generated material information, which represents the appearance of each primitive
  89343. */
  89344. _materials: IMaterial[];
  89345. _materialMap: {
  89346. [materialID: number]: number;
  89347. };
  89348. /**
  89349. * Stores all the generated texture information, which is referenced by glTF materials
  89350. */
  89351. _textures: ITexture[];
  89352. /**
  89353. * Stores all the generated image information, which is referenced by glTF textures
  89354. */
  89355. _images: IImage[];
  89356. /**
  89357. * Stores all the texture samplers
  89358. */
  89359. _samplers: ISampler[];
  89360. /**
  89361. * Stores all the generated glTF skins
  89362. */
  89363. _skins: ISkin[];
  89364. /**
  89365. * Stores all the generated animation samplers, which is referenced by glTF animations
  89366. */
  89367. /**
  89368. * Stores the animations for glTF models
  89369. */
  89370. private _animations;
  89371. /**
  89372. * Stores the total amount of bytes stored in the glTF buffer
  89373. */
  89374. private _totalByteLength;
  89375. /**
  89376. * Stores a reference to the Babylon scene containing the source geometry and material information
  89377. */
  89378. _babylonScene: Scene;
  89379. /**
  89380. * Stores a map of the image data, where the key is the file name and the value
  89381. * is the image data
  89382. */
  89383. _imageData: {
  89384. [fileName: string]: {
  89385. data: Uint8Array;
  89386. mimeType: ImageMimeType;
  89387. };
  89388. };
  89389. protected _orderedImageData: Array<{
  89390. data: Uint8Array;
  89391. mimeType: ImageMimeType;
  89392. }>;
  89393. /**
  89394. * Stores a map of the unique id of a node to its index in the node array
  89395. */
  89396. _nodeMap: {
  89397. [key: number]: number;
  89398. };
  89399. /**
  89400. * Specifies if the source Babylon scene was left handed, and needed conversion.
  89401. */
  89402. _convertToRightHandedSystem: boolean;
  89403. /**
  89404. * Specifies if a Babylon node should be converted to right-handed on export
  89405. */
  89406. _convertToRightHandedSystemMap: {
  89407. [nodeId: number]: boolean;
  89408. };
  89409. _includeCoordinateSystemConversionNodes: boolean;
  89410. /**
  89411. * Baked animation sample rate
  89412. */
  89413. private _animationSampleRate;
  89414. private _options;
  89415. private _localEngine;
  89416. _glTFMaterialExporter: _GLTFMaterialExporter;
  89417. private _extensions;
  89418. private static _ExtensionNames;
  89419. private static _ExtensionFactories;
  89420. private _applyExtension;
  89421. private _applyExtensions;
  89422. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  89423. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  89424. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89425. [key: number]: number;
  89426. }): Promise<Nullable<INode>>;
  89427. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  89428. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  89429. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89430. private _forEachExtensions;
  89431. private _extensionsOnExporting;
  89432. /**
  89433. * Load glTF serializer extensions
  89434. */
  89435. private _loadExtensions;
  89436. /**
  89437. * Creates a glTF Exporter instance, which can accept optional exporter options
  89438. * @param babylonScene Babylon scene object
  89439. * @param options Options to modify the behavior of the exporter
  89440. */
  89441. constructor(babylonScene: Scene, options?: IExportOptions);
  89442. dispose(): void;
  89443. /**
  89444. * Registers a glTF exporter extension
  89445. * @param name Name of the extension to export
  89446. * @param factory The factory function that creates the exporter extension
  89447. */
  89448. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  89449. /**
  89450. * Un-registers an exporter extension
  89451. * @param name The name fo the exporter extension
  89452. * @returns A boolean indicating whether the extension has been un-registered
  89453. */
  89454. static UnregisterExtension(name: string): boolean;
  89455. private reorderIndicesBasedOnPrimitiveMode;
  89456. /**
  89457. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  89458. * clock-wise during export to glTF
  89459. * @param submesh BabylonJS submesh
  89460. * @param primitiveMode Primitive mode of the mesh
  89461. * @param sideOrientation the winding order of the submesh
  89462. * @param vertexBufferKind The type of vertex attribute
  89463. * @param meshAttributeArray The vertex attribute data
  89464. * @param byteOffset The offset to the binary data
  89465. * @param binaryWriter The binary data for the glTF file
  89466. * @param convertToRightHandedSystem Converts the values to right-handed
  89467. */
  89468. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  89469. /**
  89470. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  89471. * clock-wise during export to glTF
  89472. * @param submesh BabylonJS submesh
  89473. * @param primitiveMode Primitive mode of the mesh
  89474. * @param sideOrientation the winding order of the submesh
  89475. * @param vertexBufferKind The type of vertex attribute
  89476. * @param meshAttributeArray The vertex attribute data
  89477. * @param byteOffset The offset to the binary data
  89478. * @param binaryWriter The binary data for the glTF file
  89479. * @param convertToRightHandedSystem Converts the values to right-handed
  89480. */
  89481. private reorderTriangleFillMode;
  89482. /**
  89483. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  89484. * clock-wise during export to glTF
  89485. * @param submesh BabylonJS submesh
  89486. * @param primitiveMode Primitive mode of the mesh
  89487. * @param sideOrientation the winding order of the submesh
  89488. * @param vertexBufferKind The type of vertex attribute
  89489. * @param meshAttributeArray The vertex attribute data
  89490. * @param byteOffset The offset to the binary data
  89491. * @param binaryWriter The binary data for the glTF file
  89492. * @param convertToRightHandedSystem Converts the values to right-handed
  89493. */
  89494. private reorderTriangleStripDrawMode;
  89495. /**
  89496. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  89497. * clock-wise during export to glTF
  89498. * @param submesh BabylonJS submesh
  89499. * @param primitiveMode Primitive mode of the mesh
  89500. * @param sideOrientation the winding order of the submesh
  89501. * @param vertexBufferKind The type of vertex attribute
  89502. * @param meshAttributeArray The vertex attribute data
  89503. * @param byteOffset The offset to the binary data
  89504. * @param binaryWriter The binary data for the glTF file
  89505. * @param convertToRightHandedSystem Converts the values to right-handed
  89506. */
  89507. private reorderTriangleFanMode;
  89508. /**
  89509. * Writes the vertex attribute data to binary
  89510. * @param vertices The vertices to write to the binary writer
  89511. * @param byteOffset The offset into the binary writer to overwrite binary data
  89512. * @param vertexAttributeKind The vertex attribute type
  89513. * @param meshAttributeArray The vertex attribute data
  89514. * @param binaryWriter The writer containing the binary data
  89515. * @param convertToRightHandedSystem Converts the values to right-handed
  89516. */
  89517. private writeVertexAttributeData;
  89518. /**
  89519. * Writes mesh attribute data to a data buffer
  89520. * Returns the bytelength of the data
  89521. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89522. * @param meshAttributeArray Array containing the attribute data
  89523. * @param byteStride Specifies the space between data
  89524. * @param binaryWriter The buffer to write the binary data to
  89525. * @param convertToRightHandedSystem Converts the values to right-handed
  89526. */
  89527. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  89528. /**
  89529. * Writes mesh attribute data to a data buffer
  89530. * Returns the bytelength of the data
  89531. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89532. * @param meshAttributeArray Array containing the attribute data
  89533. * @param byteStride Specifies the space between data
  89534. * @param binaryWriter The buffer to write the binary data to
  89535. * @param convertToRightHandedSystem Converts the values to right-handed
  89536. */
  89537. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  89538. /**
  89539. * Generates glTF json data
  89540. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  89541. * @param glTFPrefix Text to use when prefixing a glTF file
  89542. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  89543. * @returns json data as string
  89544. */
  89545. private generateJSON;
  89546. /**
  89547. * Generates data for .gltf and .bin files based on the glTF prefix string
  89548. * @param glTFPrefix Text to use when prefixing a glTF file
  89549. * @param dispose Dispose the exporter
  89550. * @returns GLTFData with glTF file data
  89551. */
  89552. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89553. /**
  89554. * Creates a binary buffer for glTF
  89555. * @returns array buffer for binary data
  89556. */
  89557. private _generateBinaryAsync;
  89558. /**
  89559. * Pads the number to a multiple of 4
  89560. * @param num number to pad
  89561. * @returns padded number
  89562. */
  89563. private _getPadding;
  89564. /**
  89565. * @hidden
  89566. */
  89567. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89568. /**
  89569. * Sets the TRS for each node
  89570. * @param node glTF Node for storing the transformation data
  89571. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  89572. * @param convertToRightHandedSystem Converts the values to right-handed
  89573. */
  89574. private setNodeTransformation;
  89575. private getVertexBufferFromMesh;
  89576. /**
  89577. * Creates a bufferview based on the vertices type for the Babylon mesh
  89578. * @param kind Indicates the type of vertices data
  89579. * @param componentType Indicates the numerical type used to store the data
  89580. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  89581. * @param binaryWriter The buffer to write the bufferview data to
  89582. * @param convertToRightHandedSystem Converts the values to right-handed
  89583. */
  89584. private createBufferViewKind;
  89585. /**
  89586. * Creates a bufferview based on the vertices type for the Babylon mesh
  89587. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  89588. * @param babylonMorphTarget the morph target to be exported
  89589. * @param binaryWriter The buffer to write the bufferview data to
  89590. * @param convertToRightHandedSystem Converts the values to right-handed
  89591. */
  89592. private setMorphTargetAttributes;
  89593. /**
  89594. * The primitive mode of the Babylon mesh
  89595. * @param babylonMesh The BabylonJS mesh
  89596. */
  89597. private getMeshPrimitiveMode;
  89598. /**
  89599. * Sets the primitive mode of the glTF mesh primitive
  89600. * @param meshPrimitive glTF mesh primitive
  89601. * @param primitiveMode The primitive mode
  89602. */
  89603. private setPrimitiveMode;
  89604. /**
  89605. * Sets the vertex attribute accessor based of the glTF mesh primitive
  89606. * @param meshPrimitive glTF mesh primitive
  89607. * @param attributeKind vertex attribute
  89608. * @returns boolean specifying if uv coordinates are present
  89609. */
  89610. private setAttributeKind;
  89611. /**
  89612. * Sets data for the primitive attributes of each submesh
  89613. * @param mesh glTF Mesh object to store the primitive attribute information
  89614. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  89615. * @param binaryWriter Buffer to write the attribute data to
  89616. * @param convertToRightHandedSystem Converts the values to right-handed
  89617. */
  89618. private setPrimitiveAttributesAsync;
  89619. /**
  89620. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  89621. * @param node The node to check
  89622. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  89623. */
  89624. private isBabylonCoordinateSystemConvertingNode;
  89625. /**
  89626. * Creates a glTF scene based on the array of meshes
  89627. * Returns the the total byte offset
  89628. * @param babylonScene Babylon scene to get the mesh data from
  89629. * @param binaryWriter Buffer to write binary data to
  89630. */
  89631. private createSceneAsync;
  89632. /**
  89633. * Creates a mapping of Node unique id to node index and handles animations
  89634. * @param babylonScene Babylon Scene
  89635. * @param nodes Babylon transform nodes
  89636. * @param binaryWriter Buffer to write binary data to
  89637. * @returns Node mapping of unique id to index
  89638. */
  89639. private createNodeMapAndAnimationsAsync;
  89640. /**
  89641. * Creates a glTF node from a Babylon mesh
  89642. * @param babylonMesh Source Babylon mesh
  89643. * @param binaryWriter Buffer for storing geometry data
  89644. * @param convertToRightHandedSystem Converts the values to right-handed
  89645. * @param nodeMap Node mapping of unique id to glTF node index
  89646. * @returns glTF node
  89647. */
  89648. private createNodeAsync;
  89649. /**
  89650. * Creates a glTF skin from a Babylon skeleton
  89651. * @param babylonScene Babylon Scene
  89652. * @param nodes Babylon transform nodes
  89653. * @param binaryWriter Buffer to write binary data to
  89654. * @returns Node mapping of unique id to index
  89655. */
  89656. private createSkinsAsync;
  89657. }
  89658. /**
  89659. * @hidden
  89660. *
  89661. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  89662. */
  89663. export class _BinaryWriter {
  89664. /**
  89665. * Array buffer which stores all binary data
  89666. */
  89667. private _arrayBuffer;
  89668. /**
  89669. * View of the array buffer
  89670. */
  89671. private _dataView;
  89672. /**
  89673. * byte offset of data in array buffer
  89674. */
  89675. private _byteOffset;
  89676. /**
  89677. * Initialize binary writer with an initial byte length
  89678. * @param byteLength Initial byte length of the array buffer
  89679. */
  89680. constructor(byteLength: number);
  89681. /**
  89682. * Resize the array buffer to the specified byte length
  89683. * @param byteLength
  89684. */
  89685. private resizeBuffer;
  89686. /**
  89687. * Get an array buffer with the length of the byte offset
  89688. * @returns ArrayBuffer resized to the byte offset
  89689. */
  89690. getArrayBuffer(): ArrayBuffer;
  89691. /**
  89692. * Get the byte offset of the array buffer
  89693. * @returns byte offset
  89694. */
  89695. getByteOffset(): number;
  89696. /**
  89697. * Stores an UInt8 in the array buffer
  89698. * @param entry
  89699. * @param byteOffset If defined, specifies where to set the value as an offset.
  89700. */
  89701. setUInt8(entry: number, byteOffset?: number): void;
  89702. /**
  89703. * Stores an UInt16 in the array buffer
  89704. * @param entry
  89705. * @param byteOffset If defined, specifies where to set the value as an offset.
  89706. */
  89707. setUInt16(entry: number, byteOffset?: number): void;
  89708. /**
  89709. * Gets an UInt32 in the array buffer
  89710. * @param entry
  89711. * @param byteOffset If defined, specifies where to set the value as an offset.
  89712. */
  89713. getUInt32(byteOffset: number): number;
  89714. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  89715. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  89716. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  89717. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  89718. /**
  89719. * Stores a Float32 in the array buffer
  89720. * @param entry
  89721. */
  89722. setFloat32(entry: number, byteOffset?: number): void;
  89723. /**
  89724. * Stores an UInt32 in the array buffer
  89725. * @param entry
  89726. * @param byteOffset If defined, specifies where to set the value as an offset.
  89727. */
  89728. setUInt32(entry: number, byteOffset?: number): void;
  89729. }
  89730. }
  89731. declare module BABYLON.GLTF2.Exporter {
  89732. /**
  89733. * @hidden
  89734. * Interface to store animation data.
  89735. */
  89736. export interface _IAnimationData {
  89737. /**
  89738. * Keyframe data.
  89739. */
  89740. inputs: number[];
  89741. /**
  89742. * Value data.
  89743. */
  89744. outputs: number[][];
  89745. /**
  89746. * Animation interpolation data.
  89747. */
  89748. samplerInterpolation: AnimationSamplerInterpolation;
  89749. /**
  89750. * Minimum keyframe value.
  89751. */
  89752. inputsMin: number;
  89753. /**
  89754. * Maximum keyframe value.
  89755. */
  89756. inputsMax: number;
  89757. }
  89758. /**
  89759. * @hidden
  89760. */
  89761. export interface _IAnimationInfo {
  89762. /**
  89763. * The target channel for the animation
  89764. */
  89765. animationChannelTargetPath: AnimationChannelTargetPath;
  89766. /**
  89767. * The glTF accessor type for the data.
  89768. */
  89769. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  89770. /**
  89771. * Specifies if quaternions should be used.
  89772. */
  89773. useQuaternion: boolean;
  89774. }
  89775. /**
  89776. * @hidden
  89777. * Utility class for generating glTF animation data from BabylonJS.
  89778. */
  89779. export class _GLTFAnimation {
  89780. /**
  89781. * @ignore
  89782. *
  89783. * Creates glTF channel animation from BabylonJS animation.
  89784. * @param babylonTransformNode - BabylonJS mesh.
  89785. * @param animation - animation.
  89786. * @param animationChannelTargetPath - The target animation channel.
  89787. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  89788. * @param useQuaternion - Specifies if quaternions are used.
  89789. * @returns nullable IAnimationData
  89790. */
  89791. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  89792. private static _DeduceAnimationInfo;
  89793. /**
  89794. * @ignore
  89795. * Create node animations from the transform node animations
  89796. * @param babylonNode
  89797. * @param runtimeGLTFAnimation
  89798. * @param idleGLTFAnimations
  89799. * @param nodeMap
  89800. * @param nodes
  89801. * @param binaryWriter
  89802. * @param bufferViews
  89803. * @param accessors
  89804. * @param convertToRightHandedSystem
  89805. * @param animationSampleRate
  89806. */
  89807. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  89808. [key: number]: number;
  89809. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  89810. /**
  89811. * @ignore
  89812. * Create individual morph animations from the mesh's morph target animation tracks
  89813. * @param babylonNode
  89814. * @param runtimeGLTFAnimation
  89815. * @param idleGLTFAnimations
  89816. * @param nodeMap
  89817. * @param nodes
  89818. * @param binaryWriter
  89819. * @param bufferViews
  89820. * @param accessors
  89821. * @param convertToRightHandedSystem
  89822. * @param animationSampleRate
  89823. */
  89824. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  89825. [key: number]: number;
  89826. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  89827. /**
  89828. * @ignore
  89829. * Create node and morph animations from the animation groups
  89830. * @param babylonScene
  89831. * @param glTFAnimations
  89832. * @param nodeMap
  89833. * @param nodes
  89834. * @param binaryWriter
  89835. * @param bufferViews
  89836. * @param accessors
  89837. * @param convertToRightHandedSystemMap
  89838. * @param animationSampleRate
  89839. */
  89840. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  89841. [key: number]: number;
  89842. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  89843. [nodeId: number]: boolean;
  89844. }, animationSampleRate: number): void;
  89845. private static AddAnimation;
  89846. /**
  89847. * Create a baked animation
  89848. * @param babylonTransformNode BabylonJS mesh
  89849. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  89850. * @param animationChannelTargetPath animation target channel
  89851. * @param minFrame minimum animation frame
  89852. * @param maxFrame maximum animation frame
  89853. * @param fps frames per second of the animation
  89854. * @param inputs input key frames of the animation
  89855. * @param outputs output key frame data of the animation
  89856. * @param convertToRightHandedSystem converts the values to right-handed
  89857. * @param useQuaternion specifies if quaternions should be used
  89858. */
  89859. private static _CreateBakedAnimation;
  89860. private static _ConvertFactorToVector3OrQuaternion;
  89861. private static _SetInterpolatedValue;
  89862. /**
  89863. * Creates linear animation from the animation key frames
  89864. * @param babylonTransformNode BabylonJS mesh
  89865. * @param animation BabylonJS animation
  89866. * @param animationChannelTargetPath The target animation channel
  89867. * @param frameDelta The difference between the last and first frame of the animation
  89868. * @param inputs Array to store the key frame times
  89869. * @param outputs Array to store the key frame data
  89870. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  89871. * @param useQuaternion Specifies if quaternions are used in the animation
  89872. */
  89873. private static _CreateLinearOrStepAnimation;
  89874. /**
  89875. * Creates cubic spline animation from the animation key frames
  89876. * @param babylonTransformNode BabylonJS mesh
  89877. * @param animation BabylonJS animation
  89878. * @param animationChannelTargetPath The target animation channel
  89879. * @param frameDelta The difference between the last and first frame of the animation
  89880. * @param inputs Array to store the key frame times
  89881. * @param outputs Array to store the key frame data
  89882. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  89883. * @param useQuaternion Specifies if quaternions are used in the animation
  89884. */
  89885. private static _CreateCubicSplineAnimation;
  89886. private static _GetBasePositionRotationOrScale;
  89887. /**
  89888. * Adds a key frame value
  89889. * @param keyFrame
  89890. * @param animation
  89891. * @param outputs
  89892. * @param animationChannelTargetPath
  89893. * @param basePositionRotationOrScale
  89894. * @param convertToRightHandedSystem
  89895. * @param useQuaternion
  89896. */
  89897. private static _AddKeyframeValue;
  89898. /**
  89899. * Determine the interpolation based on the key frames
  89900. * @param keyFrames
  89901. * @param animationChannelTargetPath
  89902. * @param useQuaternion
  89903. */
  89904. private static _DeduceInterpolation;
  89905. /**
  89906. * Adds an input tangent or output tangent to the output data
  89907. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  89908. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  89909. * @param outputs The animation data by keyframe
  89910. * @param animationChannelTargetPath The target animation channel
  89911. * @param interpolation The interpolation type
  89912. * @param keyFrame The key frame with the animation data
  89913. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  89914. * @param useQuaternion Specifies if quaternions are used
  89915. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  89916. */
  89917. private static AddSplineTangent;
  89918. /**
  89919. * Get the minimum and maximum key frames' frame values
  89920. * @param keyFrames animation key frames
  89921. * @returns the minimum and maximum key frame value
  89922. */
  89923. private static calculateMinMaxKeyFrames;
  89924. }
  89925. }
  89926. declare module BABYLON.GLTF2.Exporter {
  89927. /** @hidden */
  89928. export var textureTransformPixelShader: {
  89929. name: string;
  89930. shader: string;
  89931. };
  89932. }
  89933. declare module BABYLON.GLTF2.Exporter.Extensions {
  89934. /**
  89935. * @hidden
  89936. */
  89937. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  89938. private _recordedTextures;
  89939. /** Name of this extension */
  89940. readonly name: string;
  89941. /** Defines whether this extension is enabled */
  89942. enabled: boolean;
  89943. /** Defines whether this extension is required */
  89944. required: boolean;
  89945. /** Reference to the glTF exporter */
  89946. private _wasUsed;
  89947. constructor(exporter: _Exporter);
  89948. dispose(): void;
  89949. /** @hidden */
  89950. get wasUsed(): boolean;
  89951. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  89952. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  89953. /**
  89954. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  89955. * @param babylonTexture
  89956. * @param offset
  89957. * @param rotation
  89958. * @param scale
  89959. * @param scene
  89960. */
  89961. private _textureTransformTextureAsync;
  89962. }
  89963. }
  89964. declare module BABYLON.GLTF2.Exporter.Extensions {
  89965. /**
  89966. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  89967. */
  89968. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  89969. /** The name of this extension. */
  89970. readonly name: string;
  89971. /** Defines whether this extension is enabled. */
  89972. enabled: boolean;
  89973. /** Defines whether this extension is required */
  89974. required: boolean;
  89975. /** Reference to the glTF exporter */
  89976. private _exporter;
  89977. private _lights;
  89978. /** @hidden */
  89979. constructor(exporter: _Exporter);
  89980. /** @hidden */
  89981. dispose(): void;
  89982. /** @hidden */
  89983. get wasUsed(): boolean;
  89984. /** @hidden */
  89985. onExporting(): void;
  89986. /**
  89987. * Define this method to modify the default behavior when exporting a node
  89988. * @param context The context when exporting the node
  89989. * @param node glTF node
  89990. * @param babylonNode BabylonJS node
  89991. * @param nodeMap Node mapping of unique id to glTF node index
  89992. * @returns nullable INode promise
  89993. */
  89994. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89995. [key: number]: number;
  89996. }): Promise<Nullable<INode>>;
  89997. }
  89998. }
  89999. declare module BABYLON.GLTF2.Exporter.Extensions {
  90000. /**
  90001. * @hidden
  90002. */
  90003. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  90004. /** Name of this extension */
  90005. readonly name: string;
  90006. /** Defines whether this extension is enabled */
  90007. enabled: boolean;
  90008. /** Defines whether this extension is required */
  90009. required: boolean;
  90010. /** Reference to the glTF exporter */
  90011. private _textureInfos;
  90012. private _exportedTextures;
  90013. private _wasUsed;
  90014. constructor(exporter: _Exporter);
  90015. dispose(): void;
  90016. /** @hidden */
  90017. get wasUsed(): boolean;
  90018. private _getTextureIndex;
  90019. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90020. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90021. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90022. }
  90023. }
  90024. declare module BABYLON.GLTF2.Exporter.Extensions {
  90025. /**
  90026. * @hidden
  90027. */
  90028. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  90029. /** Name of this extension */
  90030. readonly name: string;
  90031. /** Defines whether this extension is enabled */
  90032. enabled: boolean;
  90033. /** Defines whether this extension is required */
  90034. required: boolean;
  90035. private _wasUsed;
  90036. constructor(exporter: _Exporter);
  90037. /** @hidden */
  90038. get wasUsed(): boolean;
  90039. dispose(): void;
  90040. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90041. }
  90042. }
  90043. declare module BABYLON {
  90044. /**
  90045. * Class for generating STL data from a Babylon scene.
  90046. */
  90047. export class STLExport {
  90048. /**
  90049. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  90050. * @param meshes list defines the mesh to serialize
  90051. * @param download triggers the automatic download of the file.
  90052. * @param fileName changes the downloads fileName.
  90053. * @param binary changes the STL to a binary type.
  90054. * @param isLittleEndian toggle for binary type exporter.
  90055. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  90056. * @returns the STL as UTF8 string
  90057. */
  90058. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  90059. }
  90060. }
  90061. declare module "babylonjs-gltf2interface" {
  90062. export = BABYLON.GLTF2;
  90063. }
  90064. /**
  90065. * Module for glTF 2.0 Interface
  90066. */
  90067. declare module BABYLON.GLTF2 {
  90068. /**
  90069. * The datatype of the components in the attribute
  90070. */
  90071. const enum AccessorComponentType {
  90072. /**
  90073. * Byte
  90074. */
  90075. BYTE = 5120,
  90076. /**
  90077. * Unsigned Byte
  90078. */
  90079. UNSIGNED_BYTE = 5121,
  90080. /**
  90081. * Short
  90082. */
  90083. SHORT = 5122,
  90084. /**
  90085. * Unsigned Short
  90086. */
  90087. UNSIGNED_SHORT = 5123,
  90088. /**
  90089. * Unsigned Int
  90090. */
  90091. UNSIGNED_INT = 5125,
  90092. /**
  90093. * Float
  90094. */
  90095. FLOAT = 5126,
  90096. }
  90097. /**
  90098. * Specifies if the attirbute is a scalar, vector, or matrix
  90099. */
  90100. const enum AccessorType {
  90101. /**
  90102. * Scalar
  90103. */
  90104. SCALAR = "SCALAR",
  90105. /**
  90106. * Vector2
  90107. */
  90108. VEC2 = "VEC2",
  90109. /**
  90110. * Vector3
  90111. */
  90112. VEC3 = "VEC3",
  90113. /**
  90114. * Vector4
  90115. */
  90116. VEC4 = "VEC4",
  90117. /**
  90118. * Matrix2x2
  90119. */
  90120. MAT2 = "MAT2",
  90121. /**
  90122. * Matrix3x3
  90123. */
  90124. MAT3 = "MAT3",
  90125. /**
  90126. * Matrix4x4
  90127. */
  90128. MAT4 = "MAT4",
  90129. }
  90130. /**
  90131. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90132. */
  90133. const enum AnimationChannelTargetPath {
  90134. /**
  90135. * Translation
  90136. */
  90137. TRANSLATION = "translation",
  90138. /**
  90139. * Rotation
  90140. */
  90141. ROTATION = "rotation",
  90142. /**
  90143. * Scale
  90144. */
  90145. SCALE = "scale",
  90146. /**
  90147. * Weights
  90148. */
  90149. WEIGHTS = "weights",
  90150. }
  90151. /**
  90152. * Interpolation algorithm
  90153. */
  90154. const enum AnimationSamplerInterpolation {
  90155. /**
  90156. * The animated values are linearly interpolated between keyframes
  90157. */
  90158. LINEAR = "LINEAR",
  90159. /**
  90160. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  90161. */
  90162. STEP = "STEP",
  90163. /**
  90164. * The animation's interpolation is computed using a cubic spline with specified tangents
  90165. */
  90166. CUBICSPLINE = "CUBICSPLINE",
  90167. }
  90168. /**
  90169. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90170. */
  90171. const enum CameraType {
  90172. /**
  90173. * A perspective camera containing properties to create a perspective projection matrix
  90174. */
  90175. PERSPECTIVE = "perspective",
  90176. /**
  90177. * An orthographic camera containing properties to create an orthographic projection matrix
  90178. */
  90179. ORTHOGRAPHIC = "orthographic",
  90180. }
  90181. /**
  90182. * The mime-type of the image
  90183. */
  90184. const enum ImageMimeType {
  90185. /**
  90186. * JPEG Mime-type
  90187. */
  90188. JPEG = "image/jpeg",
  90189. /**
  90190. * PNG Mime-type
  90191. */
  90192. PNG = "image/png",
  90193. }
  90194. /**
  90195. * The alpha rendering mode of the material
  90196. */
  90197. const enum MaterialAlphaMode {
  90198. /**
  90199. * The alpha value is ignored and the rendered output is fully opaque
  90200. */
  90201. OPAQUE = "OPAQUE",
  90202. /**
  90203. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  90204. */
  90205. MASK = "MASK",
  90206. /**
  90207. * 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)
  90208. */
  90209. BLEND = "BLEND",
  90210. }
  90211. /**
  90212. * The type of the primitives to render
  90213. */
  90214. const enum MeshPrimitiveMode {
  90215. /**
  90216. * Points
  90217. */
  90218. POINTS = 0,
  90219. /**
  90220. * Lines
  90221. */
  90222. LINES = 1,
  90223. /**
  90224. * Line Loop
  90225. */
  90226. LINE_LOOP = 2,
  90227. /**
  90228. * Line Strip
  90229. */
  90230. LINE_STRIP = 3,
  90231. /**
  90232. * Triangles
  90233. */
  90234. TRIANGLES = 4,
  90235. /**
  90236. * Triangle Strip
  90237. */
  90238. TRIANGLE_STRIP = 5,
  90239. /**
  90240. * Triangle Fan
  90241. */
  90242. TRIANGLE_FAN = 6,
  90243. }
  90244. /**
  90245. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90246. */
  90247. const enum TextureMagFilter {
  90248. /**
  90249. * Nearest
  90250. */
  90251. NEAREST = 9728,
  90252. /**
  90253. * Linear
  90254. */
  90255. LINEAR = 9729,
  90256. }
  90257. /**
  90258. * Minification filter. All valid values correspond to WebGL enums
  90259. */
  90260. const enum TextureMinFilter {
  90261. /**
  90262. * Nearest
  90263. */
  90264. NEAREST = 9728,
  90265. /**
  90266. * Linear
  90267. */
  90268. LINEAR = 9729,
  90269. /**
  90270. * Nearest Mip-Map Nearest
  90271. */
  90272. NEAREST_MIPMAP_NEAREST = 9984,
  90273. /**
  90274. * Linear Mipmap Nearest
  90275. */
  90276. LINEAR_MIPMAP_NEAREST = 9985,
  90277. /**
  90278. * Nearest Mipmap Linear
  90279. */
  90280. NEAREST_MIPMAP_LINEAR = 9986,
  90281. /**
  90282. * Linear Mipmap Linear
  90283. */
  90284. LINEAR_MIPMAP_LINEAR = 9987,
  90285. }
  90286. /**
  90287. * S (U) wrapping mode. All valid values correspond to WebGL enums
  90288. */
  90289. const enum TextureWrapMode {
  90290. /**
  90291. * Clamp to Edge
  90292. */
  90293. CLAMP_TO_EDGE = 33071,
  90294. /**
  90295. * Mirrored Repeat
  90296. */
  90297. MIRRORED_REPEAT = 33648,
  90298. /**
  90299. * Repeat
  90300. */
  90301. REPEAT = 10497,
  90302. }
  90303. /**
  90304. * glTF Property
  90305. */
  90306. interface IProperty {
  90307. /**
  90308. * Dictionary object with extension-specific objects
  90309. */
  90310. extensions?: {
  90311. [key: string]: any;
  90312. };
  90313. /**
  90314. * Application-Specific data
  90315. */
  90316. extras?: any;
  90317. }
  90318. /**
  90319. * glTF Child of Root Property
  90320. */
  90321. interface IChildRootProperty extends IProperty {
  90322. /**
  90323. * The user-defined name of this object
  90324. */
  90325. name?: string;
  90326. }
  90327. /**
  90328. * Indices of those attributes that deviate from their initialization value
  90329. */
  90330. interface IAccessorSparseIndices extends IProperty {
  90331. /**
  90332. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90333. */
  90334. bufferView: number;
  90335. /**
  90336. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90337. */
  90338. byteOffset?: number;
  90339. /**
  90340. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  90341. */
  90342. componentType: AccessorComponentType;
  90343. }
  90344. /**
  90345. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  90346. */
  90347. interface IAccessorSparseValues extends IProperty {
  90348. /**
  90349. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90350. */
  90351. bufferView: number;
  90352. /**
  90353. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90354. */
  90355. byteOffset?: number;
  90356. }
  90357. /**
  90358. * Sparse storage of attributes that deviate from their initialization value
  90359. */
  90360. interface IAccessorSparse extends IProperty {
  90361. /**
  90362. * The number of attributes encoded in this sparse accessor
  90363. */
  90364. count: number;
  90365. /**
  90366. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  90367. */
  90368. indices: IAccessorSparseIndices;
  90369. /**
  90370. * 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
  90371. */
  90372. values: IAccessorSparseValues;
  90373. }
  90374. /**
  90375. * 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
  90376. */
  90377. interface IAccessor extends IChildRootProperty {
  90378. /**
  90379. * The index of the bufferview
  90380. */
  90381. bufferView?: number;
  90382. /**
  90383. * The offset relative to the start of the bufferView in bytes
  90384. */
  90385. byteOffset?: number;
  90386. /**
  90387. * The datatype of components in the attribute
  90388. */
  90389. componentType: AccessorComponentType;
  90390. /**
  90391. * Specifies whether integer data values should be normalized
  90392. */
  90393. normalized?: boolean;
  90394. /**
  90395. * The number of attributes referenced by this accessor
  90396. */
  90397. count: number;
  90398. /**
  90399. * Specifies if the attribute is a scalar, vector, or matrix
  90400. */
  90401. type: AccessorType;
  90402. /**
  90403. * Maximum value of each component in this attribute
  90404. */
  90405. max?: number[];
  90406. /**
  90407. * Minimum value of each component in this attribute
  90408. */
  90409. min?: number[];
  90410. /**
  90411. * Sparse storage of attributes that deviate from their initialization value
  90412. */
  90413. sparse?: IAccessorSparse;
  90414. }
  90415. /**
  90416. * Targets an animation's sampler at a node's property
  90417. */
  90418. interface IAnimationChannel extends IProperty {
  90419. /**
  90420. * The index of a sampler in this animation used to compute the value for the target
  90421. */
  90422. sampler: number;
  90423. /**
  90424. * The index of the node and TRS property to target
  90425. */
  90426. target: IAnimationChannelTarget;
  90427. }
  90428. /**
  90429. * The index of the node and TRS property that an animation channel targets
  90430. */
  90431. interface IAnimationChannelTarget extends IProperty {
  90432. /**
  90433. * The index of the node to target
  90434. */
  90435. node: number;
  90436. /**
  90437. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90438. */
  90439. path: AnimationChannelTargetPath;
  90440. }
  90441. /**
  90442. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90443. */
  90444. interface IAnimationSampler extends IProperty {
  90445. /**
  90446. * The index of an accessor containing keyframe input values, e.g., time
  90447. */
  90448. input: number;
  90449. /**
  90450. * Interpolation algorithm
  90451. */
  90452. interpolation?: AnimationSamplerInterpolation;
  90453. /**
  90454. * The index of an accessor, containing keyframe output values
  90455. */
  90456. output: number;
  90457. }
  90458. /**
  90459. * A keyframe animation
  90460. */
  90461. interface IAnimation extends IChildRootProperty {
  90462. /**
  90463. * An array of channels, each of which targets an animation's sampler at a node's property
  90464. */
  90465. channels: IAnimationChannel[];
  90466. /**
  90467. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90468. */
  90469. samplers: IAnimationSampler[];
  90470. }
  90471. /**
  90472. * Metadata about the glTF asset
  90473. */
  90474. interface IAsset extends IChildRootProperty {
  90475. /**
  90476. * A copyright message suitable for display to credit the content creator
  90477. */
  90478. copyright?: string;
  90479. /**
  90480. * Tool that generated this glTF model. Useful for debugging
  90481. */
  90482. generator?: string;
  90483. /**
  90484. * The glTF version that this asset targets
  90485. */
  90486. version: string;
  90487. /**
  90488. * The minimum glTF version that this asset targets
  90489. */
  90490. minVersion?: string;
  90491. }
  90492. /**
  90493. * A buffer points to binary geometry, animation, or skins
  90494. */
  90495. interface IBuffer extends IChildRootProperty {
  90496. /**
  90497. * 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
  90498. */
  90499. uri?: string;
  90500. /**
  90501. * The length of the buffer in bytes
  90502. */
  90503. byteLength: number;
  90504. }
  90505. /**
  90506. * A view into a buffer generally representing a subset of the buffer
  90507. */
  90508. interface IBufferView extends IChildRootProperty {
  90509. /**
  90510. * The index of the buffer
  90511. */
  90512. buffer: number;
  90513. /**
  90514. * The offset into the buffer in bytes
  90515. */
  90516. byteOffset?: number;
  90517. /**
  90518. * The lenth of the bufferView in bytes
  90519. */
  90520. byteLength: number;
  90521. /**
  90522. * The stride, in bytes
  90523. */
  90524. byteStride?: number;
  90525. }
  90526. /**
  90527. * An orthographic camera containing properties to create an orthographic projection matrix
  90528. */
  90529. interface ICameraOrthographic extends IProperty {
  90530. /**
  90531. * The floating-point horizontal magnification of the view. Must not be zero
  90532. */
  90533. xmag: number;
  90534. /**
  90535. * The floating-point vertical magnification of the view. Must not be zero
  90536. */
  90537. ymag: number;
  90538. /**
  90539. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  90540. */
  90541. zfar: number;
  90542. /**
  90543. * The floating-point distance to the near clipping plane
  90544. */
  90545. znear: number;
  90546. }
  90547. /**
  90548. * A perspective camera containing properties to create a perspective projection matrix
  90549. */
  90550. interface ICameraPerspective extends IProperty {
  90551. /**
  90552. * The floating-point aspect ratio of the field of view
  90553. */
  90554. aspectRatio?: number;
  90555. /**
  90556. * The floating-point vertical field of view in radians
  90557. */
  90558. yfov: number;
  90559. /**
  90560. * The floating-point distance to the far clipping plane
  90561. */
  90562. zfar?: number;
  90563. /**
  90564. * The floating-point distance to the near clipping plane
  90565. */
  90566. znear: number;
  90567. }
  90568. /**
  90569. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90570. */
  90571. interface ICamera extends IChildRootProperty {
  90572. /**
  90573. * An orthographic camera containing properties to create an orthographic projection matrix
  90574. */
  90575. orthographic?: ICameraOrthographic;
  90576. /**
  90577. * A perspective camera containing properties to create a perspective projection matrix
  90578. */
  90579. perspective?: ICameraPerspective;
  90580. /**
  90581. * Specifies if the camera uses a perspective or orthographic projection
  90582. */
  90583. type: CameraType;
  90584. }
  90585. /**
  90586. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  90587. */
  90588. interface IImage extends IChildRootProperty {
  90589. /**
  90590. * 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
  90591. */
  90592. uri?: string;
  90593. /**
  90594. * The image's MIME type
  90595. */
  90596. mimeType?: ImageMimeType;
  90597. /**
  90598. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  90599. */
  90600. bufferView?: number;
  90601. }
  90602. /**
  90603. * Material Normal Texture Info
  90604. */
  90605. interface IMaterialNormalTextureInfo extends ITextureInfo {
  90606. /**
  90607. * The scalar multiplier applied to each normal vector of the normal texture
  90608. */
  90609. scale?: number;
  90610. }
  90611. /**
  90612. * Material Occlusion Texture Info
  90613. */
  90614. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  90615. /**
  90616. * A scalar multiplier controlling the amount of occlusion applied
  90617. */
  90618. strength?: number;
  90619. }
  90620. /**
  90621. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  90622. */
  90623. interface IMaterialPbrMetallicRoughness {
  90624. /**
  90625. * The material's base color factor
  90626. */
  90627. baseColorFactor?: number[];
  90628. /**
  90629. * The base color texture
  90630. */
  90631. baseColorTexture?: ITextureInfo;
  90632. /**
  90633. * The metalness of the material
  90634. */
  90635. metallicFactor?: number;
  90636. /**
  90637. * The roughness of the material
  90638. */
  90639. roughnessFactor?: number;
  90640. /**
  90641. * The metallic-roughness texture
  90642. */
  90643. metallicRoughnessTexture?: ITextureInfo;
  90644. }
  90645. /**
  90646. * The material appearance of a primitive
  90647. */
  90648. interface IMaterial extends IChildRootProperty {
  90649. /**
  90650. * 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
  90651. */
  90652. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  90653. /**
  90654. * The normal map texture
  90655. */
  90656. normalTexture?: IMaterialNormalTextureInfo;
  90657. /**
  90658. * The occlusion map texture
  90659. */
  90660. occlusionTexture?: IMaterialOcclusionTextureInfo;
  90661. /**
  90662. * The emissive map texture
  90663. */
  90664. emissiveTexture?: ITextureInfo;
  90665. /**
  90666. * 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
  90667. */
  90668. emissiveFactor?: number[];
  90669. /**
  90670. * The alpha rendering mode of the material
  90671. */
  90672. alphaMode?: MaterialAlphaMode;
  90673. /**
  90674. * The alpha cutoff value of the material
  90675. */
  90676. alphaCutoff?: number;
  90677. /**
  90678. * Specifies whether the material is double sided
  90679. */
  90680. doubleSided?: boolean;
  90681. }
  90682. /**
  90683. * Geometry to be rendered with the given material
  90684. */
  90685. interface IMeshPrimitive extends IProperty {
  90686. /**
  90687. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  90688. */
  90689. attributes: {
  90690. [name: string]: number;
  90691. };
  90692. /**
  90693. * The index of the accessor that contains the indices
  90694. */
  90695. indices?: number;
  90696. /**
  90697. * The index of the material to apply to this primitive when rendering
  90698. */
  90699. material?: number;
  90700. /**
  90701. * The type of primitives to render. All valid values correspond to WebGL enums
  90702. */
  90703. mode?: MeshPrimitiveMode;
  90704. /**
  90705. * 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
  90706. */
  90707. targets?: {
  90708. [name: string]: number;
  90709. }[];
  90710. }
  90711. /**
  90712. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  90713. */
  90714. interface IMesh extends IChildRootProperty {
  90715. /**
  90716. * An array of primitives, each defining geometry to be rendered with a material
  90717. */
  90718. primitives: IMeshPrimitive[];
  90719. /**
  90720. * Array of weights to be applied to the Morph Targets
  90721. */
  90722. weights?: number[];
  90723. }
  90724. /**
  90725. * A node in the node hierarchy
  90726. */
  90727. interface INode extends IChildRootProperty {
  90728. /**
  90729. * The index of the camera referenced by this node
  90730. */
  90731. camera?: number;
  90732. /**
  90733. * The indices of this node's children
  90734. */
  90735. children?: number[];
  90736. /**
  90737. * The index of the skin referenced by this node
  90738. */
  90739. skin?: number;
  90740. /**
  90741. * A floating-point 4x4 transformation matrix stored in column-major order
  90742. */
  90743. matrix?: number[];
  90744. /**
  90745. * The index of the mesh in this node
  90746. */
  90747. mesh?: number;
  90748. /**
  90749. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  90750. */
  90751. rotation?: number[];
  90752. /**
  90753. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  90754. */
  90755. scale?: number[];
  90756. /**
  90757. * The node's translation along the x, y, and z axes
  90758. */
  90759. translation?: number[];
  90760. /**
  90761. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  90762. */
  90763. weights?: number[];
  90764. }
  90765. /**
  90766. * Texture sampler properties for filtering and wrapping modes
  90767. */
  90768. interface ISampler extends IChildRootProperty {
  90769. /**
  90770. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90771. */
  90772. magFilter?: TextureMagFilter;
  90773. /**
  90774. * Minification filter. All valid values correspond to WebGL enums
  90775. */
  90776. minFilter?: TextureMinFilter;
  90777. /**
  90778. * S (U) wrapping mode. All valid values correspond to WebGL enums
  90779. */
  90780. wrapS?: TextureWrapMode;
  90781. /**
  90782. * T (V) wrapping mode. All valid values correspond to WebGL enums
  90783. */
  90784. wrapT?: TextureWrapMode;
  90785. }
  90786. /**
  90787. * The root nodes of a scene
  90788. */
  90789. interface IScene extends IChildRootProperty {
  90790. /**
  90791. * The indices of each root node
  90792. */
  90793. nodes: number[];
  90794. }
  90795. /**
  90796. * Joints and matrices defining a skin
  90797. */
  90798. interface ISkin extends IChildRootProperty {
  90799. /**
  90800. * 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
  90801. */
  90802. inverseBindMatrices?: number;
  90803. /**
  90804. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  90805. */
  90806. skeleton?: number;
  90807. /**
  90808. * 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)
  90809. */
  90810. joints: number[];
  90811. }
  90812. /**
  90813. * A texture and its sampler
  90814. */
  90815. interface ITexture extends IChildRootProperty {
  90816. /**
  90817. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  90818. */
  90819. sampler?: number;
  90820. /**
  90821. * The index of the image used by this texture
  90822. */
  90823. source: number;
  90824. }
  90825. /**
  90826. * Reference to a texture
  90827. */
  90828. interface ITextureInfo extends IProperty {
  90829. /**
  90830. * The index of the texture
  90831. */
  90832. index: number;
  90833. /**
  90834. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  90835. */
  90836. texCoord?: number;
  90837. }
  90838. /**
  90839. * The root object for a glTF asset
  90840. */
  90841. interface IGLTF extends IProperty {
  90842. /**
  90843. * An array of accessors. An accessor is a typed view into a bufferView
  90844. */
  90845. accessors?: IAccessor[];
  90846. /**
  90847. * An array of keyframe animations
  90848. */
  90849. animations?: IAnimation[];
  90850. /**
  90851. * Metadata about the glTF asset
  90852. */
  90853. asset: IAsset;
  90854. /**
  90855. * An array of buffers. A buffer points to binary geometry, animation, or skins
  90856. */
  90857. buffers?: IBuffer[];
  90858. /**
  90859. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  90860. */
  90861. bufferViews?: IBufferView[];
  90862. /**
  90863. * An array of cameras
  90864. */
  90865. cameras?: ICamera[];
  90866. /**
  90867. * Names of glTF extensions used somewhere in this asset
  90868. */
  90869. extensionsUsed?: string[];
  90870. /**
  90871. * Names of glTF extensions required to properly load this asset
  90872. */
  90873. extensionsRequired?: string[];
  90874. /**
  90875. * An array of images. An image defines data used to create a texture
  90876. */
  90877. images?: IImage[];
  90878. /**
  90879. * An array of materials. A material defines the appearance of a primitive
  90880. */
  90881. materials?: IMaterial[];
  90882. /**
  90883. * An array of meshes. A mesh is a set of primitives to be rendered
  90884. */
  90885. meshes?: IMesh[];
  90886. /**
  90887. * An array of nodes
  90888. */
  90889. nodes?: INode[];
  90890. /**
  90891. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  90892. */
  90893. samplers?: ISampler[];
  90894. /**
  90895. * The index of the default scene
  90896. */
  90897. scene?: number;
  90898. /**
  90899. * An array of scenes
  90900. */
  90901. scenes?: IScene[];
  90902. /**
  90903. * An array of skins. A skin is defined by joints and matrices
  90904. */
  90905. skins?: ISkin[];
  90906. /**
  90907. * An array of textures
  90908. */
  90909. textures?: ITexture[];
  90910. }
  90911. /**
  90912. * The glTF validation results
  90913. * @ignore
  90914. */
  90915. interface IGLTFValidationResults {
  90916. info: {
  90917. generator: string;
  90918. hasAnimations: boolean;
  90919. hasDefaultScene: boolean;
  90920. hasMaterials: boolean;
  90921. hasMorphTargets: boolean;
  90922. hasSkins: boolean;
  90923. hasTextures: boolean;
  90924. maxAttributesUsed: number;
  90925. primitivesCount: number
  90926. };
  90927. issues: {
  90928. messages: Array<string>;
  90929. numErrors: number;
  90930. numHints: number;
  90931. numInfos: number;
  90932. numWarnings: number;
  90933. truncated: boolean
  90934. };
  90935. mimeType: string;
  90936. uri: string;
  90937. validatedAt: string;
  90938. validatorVersion: string;
  90939. }
  90940. /**
  90941. * The glTF validation options
  90942. */
  90943. interface IGLTFValidationOptions {
  90944. /** Uri to use */
  90945. uri?: string;
  90946. /** Function used to load external resources */
  90947. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  90948. /** Boolean indicating that we need to validate accessor data */
  90949. validateAccessorData?: boolean;
  90950. /** max number of issues allowed */
  90951. maxIssues?: number;
  90952. /** Ignored issues */
  90953. ignoredIssues?: Array<string>;
  90954. /** Value to override severy settings */
  90955. severityOverrides?: Object;
  90956. }
  90957. /**
  90958. * The glTF validator object
  90959. * @ignore
  90960. */
  90961. interface IGLTFValidator {
  90962. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  90963. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  90964. }
  90965. /**
  90966. * Interfaces from the EXT_lights_image_based extension
  90967. */
  90968. /** @hidden */
  90969. interface IEXTLightsImageBased_LightReferenceImageBased {
  90970. light: number;
  90971. }
  90972. /** @hidden */
  90973. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  90974. intensity: number;
  90975. rotation: number[];
  90976. specularImageSize: number;
  90977. specularImages: number[][];
  90978. irradianceCoefficients: number[][];
  90979. }
  90980. /** @hidden */
  90981. interface IEXTLightsImageBased {
  90982. lights: IEXTLightsImageBased_LightImageBased[];
  90983. }
  90984. /**
  90985. * Interfaces from the EXT_mesh_gpu_instancing extension
  90986. * !!! Experimental Extension Subject to Changes !!!
  90987. */
  90988. /** @hidden */
  90989. interface IEXTMeshGpuInstancing {
  90990. mesh?: number;
  90991. attributes: { [name: string]: number };
  90992. }
  90993. /**
  90994. * Interfaces from the KHR_draco_mesh_compression extension
  90995. */
  90996. /** @hidden */
  90997. interface IKHRDracoMeshCompression {
  90998. bufferView: number;
  90999. attributes: { [name: string]: number };
  91000. }
  91001. /**
  91002. * Interfaces from the KHR_lights_punctual extension
  91003. */
  91004. /** @hidden */
  91005. const enum IKHRLightsPunctual_LightType {
  91006. DIRECTIONAL = "directional",
  91007. POINT = "point",
  91008. SPOT = "spot"
  91009. }
  91010. /** @hidden */
  91011. interface IKHRLightsPunctual_LightReference {
  91012. light: number;
  91013. }
  91014. /** @hidden */
  91015. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  91016. type: IKHRLightsPunctual_LightType;
  91017. color?: number[];
  91018. intensity?: number;
  91019. range?: number;
  91020. spot?: {
  91021. innerConeAngle?: number;
  91022. outerConeAngle?: number;
  91023. };
  91024. }
  91025. /** @hidden */
  91026. interface IKHRLightsPunctual {
  91027. lights: IKHRLightsPunctual_Light[];
  91028. }
  91029. /**
  91030. * Interfaces from the KHR_materials_clearcoat extension
  91031. * !!! Experimental Extension Subject to Changes !!!
  91032. */
  91033. /** @hidden */
  91034. interface IKHRMaterialsClearcoat {
  91035. clearcoatFactor: number;
  91036. clearcoatTexture: ITextureInfo;
  91037. clearcoatRoughnessFactor: number;
  91038. clearcoatRoughnessTexture: ITextureInfo;
  91039. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  91040. }
  91041. /**
  91042. * Interfaces from the KHR_materials_ior extension
  91043. * !!! Experimental Extension Subject to Changes !!!
  91044. */
  91045. /** @hidden */
  91046. interface IKHRMaterialsIor {
  91047. ior: number;
  91048. }
  91049. /**
  91050. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  91051. */
  91052. /** @hidden */
  91053. interface IKHRMaterialsPbrSpecularGlossiness {
  91054. diffuseFactor: number[];
  91055. diffuseTexture: ITextureInfo;
  91056. specularFactor: number[];
  91057. glossinessFactor: number;
  91058. specularGlossinessTexture: ITextureInfo;
  91059. }
  91060. /**
  91061. * Interfaces from the KHR_materials_sheen extension
  91062. * !!! Experimental Extension Subject to Changes !!!
  91063. */
  91064. /** @hidden */
  91065. interface IKHRMaterialsSheen {
  91066. sheenColorFactor?: number[];
  91067. sheenColorTexture?: ITextureInfo;
  91068. sheenRoughnessFactor?: number;
  91069. sheenRoughnessTexture?: ITextureInfo;
  91070. }
  91071. /**
  91072. * Interfaces from the KHR_materials_specular extension
  91073. * !!! Experimental Extension Subject to Changes !!!
  91074. */
  91075. /** @hidden */
  91076. interface IKHRMaterialsSpecular {
  91077. specularFactor: number;
  91078. specularColorFactor: number[];
  91079. specularTexture: ITextureInfo;
  91080. }
  91081. /**
  91082. * Interfaces from the KHR_materials_transmission extension
  91083. * !!! Experimental Extension Subject to Changes !!!
  91084. */
  91085. /** @hidden */
  91086. interface IKHRMaterialsTransmission {
  91087. transmissionFactor?: number;
  91088. transmissionTexture?: ITextureInfo;
  91089. }
  91090. /**
  91091. * Interfaces from the KHR_materials_translucency extension
  91092. * !!! Experimental Extension Subject to Changes !!!
  91093. */
  91094. /** @hidden */
  91095. interface IKHRMaterialsTranslucency {
  91096. translucencyFactor?: number;
  91097. translucencyTexture?: ITextureInfo;
  91098. }
  91099. /**
  91100. * Interfaces from the KHR_materials_variants extension
  91101. * !!! Experimental Extension Subject to Changes !!!
  91102. */
  91103. /** @hidden */
  91104. interface IKHRMaterialVariants_Mapping extends IProperty {
  91105. mappings: Array<{
  91106. variants: number[];
  91107. material: number;
  91108. }>;
  91109. }
  91110. /** @hidden */
  91111. interface IKHRMaterialVariants_Variant extends IProperty {
  91112. name: string;
  91113. }
  91114. /** @hidden */
  91115. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  91116. variants: Array<IKHRMaterialVariants_Variant>;
  91117. }
  91118. /**
  91119. * Interfaces from the KHR_texture_basisu extension
  91120. * !!! Experimental Extension Subject to Changes !!!
  91121. */
  91122. /** @hidden */
  91123. interface IKHRTextureBasisU {
  91124. source: number;
  91125. }
  91126. /**
  91127. * Interfaces from the EXT_texture_webp extension
  91128. */
  91129. /** @hidden */
  91130. interface IEXTTextureWebP {
  91131. source: number;
  91132. }
  91133. /**
  91134. * Interfaces from the KHR_texture_transform extension
  91135. */
  91136. /** @hidden */
  91137. interface IKHRTextureTransform {
  91138. offset?: number[];
  91139. rotation?: number;
  91140. scale?: number[];
  91141. texCoord?: number;
  91142. }
  91143. /**
  91144. * Interfaces from the KHR_xmp extension
  91145. * !!! Experimental Extension Subject to Changes !!!
  91146. */
  91147. /** @hidden */
  91148. interface IKHRXmp_Data {
  91149. [key: string]: unknown;
  91150. }
  91151. /** @hidden */
  91152. interface IKHRXmp_Gltf {
  91153. packets: IKHRXmp_Data[];
  91154. }
  91155. /** @hidden */
  91156. interface IKHRXmp_Node {
  91157. packet: number;
  91158. }
  91159. /**
  91160. * Interfaces from the MSFT_audio_emitter extension
  91161. */
  91162. /** @hidden */
  91163. interface IMSFTAudioEmitter_ClipReference {
  91164. clip: number;
  91165. weight?: number;
  91166. }
  91167. /** @hidden */
  91168. interface IMSFTAudioEmitter_EmittersReference {
  91169. emitters: number[];
  91170. }
  91171. /** @hidden */
  91172. const enum IMSFTAudioEmitter_DistanceModel {
  91173. linear = "linear",
  91174. inverse = "inverse",
  91175. exponential = "exponential",
  91176. }
  91177. /** @hidden */
  91178. interface IMSFTAudioEmitter_Emitter {
  91179. name?: string;
  91180. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  91181. refDistance?: number;
  91182. maxDistance?: number;
  91183. rolloffFactor?: number;
  91184. innerAngle?: number;
  91185. outerAngle?: number;
  91186. loop?: boolean;
  91187. volume?: number;
  91188. clips: IMSFTAudioEmitter_ClipReference[];
  91189. }
  91190. /** @hidden */
  91191. const enum IMSFTAudioEmitter_AudioMimeType {
  91192. WAV = "audio/wav",
  91193. }
  91194. /** @hidden */
  91195. interface IMSFTAudioEmitter_Clip extends IProperty {
  91196. uri?: string;
  91197. bufferView?: number;
  91198. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  91199. }
  91200. /** @hidden */
  91201. const enum IMSFTAudioEmitter_AnimationEventAction {
  91202. play = "play",
  91203. pause = "pause",
  91204. stop = "stop",
  91205. }
  91206. /** @hidden */
  91207. interface IMSFTAudioEmitter_AnimationEvent {
  91208. action: IMSFTAudioEmitter_AnimationEventAction;
  91209. emitter: number;
  91210. time: number;
  91211. startOffset?: number;
  91212. }
  91213. /**
  91214. * Interfaces from the MSFT_lod extension
  91215. */
  91216. /** @hidden */
  91217. interface IMSFTLOD {
  91218. ids: number[];
  91219. }
  91220. /**
  91221. * Interfaces from the EXT_meshopt_compression extension
  91222. */
  91223. /** @hidden */
  91224. interface IEXTMeshoptCompression {
  91225. buffer: number;
  91226. byteOffset?: number;
  91227. byteLength: number;
  91228. byteStride: number;
  91229. count: number;
  91230. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  91231. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  91232. }
  91233. }
  91234. declare module BABYLON {
  91235. /** @hidden */
  91236. export var cellPixelShader: {
  91237. name: string;
  91238. shader: string;
  91239. };
  91240. }
  91241. declare module BABYLON {
  91242. /** @hidden */
  91243. export var cellVertexShader: {
  91244. name: string;
  91245. shader: string;
  91246. };
  91247. }
  91248. declare module BABYLON {
  91249. export class CellMaterial extends BABYLON.PushMaterial {
  91250. private _diffuseTexture;
  91251. diffuseTexture: BABYLON.BaseTexture;
  91252. diffuseColor: BABYLON.Color3;
  91253. _computeHighLevel: boolean;
  91254. computeHighLevel: boolean;
  91255. private _disableLighting;
  91256. disableLighting: boolean;
  91257. private _maxSimultaneousLights;
  91258. maxSimultaneousLights: number;
  91259. constructor(name: string, scene: BABYLON.Scene);
  91260. needAlphaBlending(): boolean;
  91261. needAlphaTesting(): boolean;
  91262. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91263. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91264. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91265. getAnimatables(): BABYLON.IAnimatable[];
  91266. getActiveTextures(): BABYLON.BaseTexture[];
  91267. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91268. dispose(forceDisposeEffect?: boolean): void;
  91269. getClassName(): string;
  91270. clone(name: string): CellMaterial;
  91271. serialize(): any;
  91272. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  91273. }
  91274. }
  91275. declare module BABYLON {
  91276. export class CustomShaderStructure {
  91277. FragmentStore: string;
  91278. VertexStore: string;
  91279. constructor();
  91280. }
  91281. export class ShaderSpecialParts {
  91282. constructor();
  91283. Fragment_Begin: string;
  91284. Fragment_Definitions: string;
  91285. Fragment_MainBegin: string;
  91286. Fragment_Custom_Diffuse: string;
  91287. Fragment_Before_Lights: string;
  91288. Fragment_Before_Fog: string;
  91289. Fragment_Custom_Alpha: string;
  91290. Fragment_Before_FragColor: string;
  91291. Vertex_Begin: string;
  91292. Vertex_Definitions: string;
  91293. Vertex_MainBegin: string;
  91294. Vertex_Before_PositionUpdated: string;
  91295. Vertex_Before_NormalUpdated: string;
  91296. Vertex_After_WorldPosComputed: string;
  91297. Vertex_MainEnd: string;
  91298. }
  91299. export class CustomMaterial extends BABYLON.StandardMaterial {
  91300. static ShaderIndexer: number;
  91301. CustomParts: ShaderSpecialParts;
  91302. _isCreatedShader: boolean;
  91303. _createdShaderName: string;
  91304. _customUniform: string[];
  91305. _newUniforms: string[];
  91306. _newUniformInstances: {
  91307. [name: string]: any;
  91308. };
  91309. _newSamplerInstances: {
  91310. [name: string]: BABYLON.Texture;
  91311. };
  91312. _customAttributes: string[];
  91313. FragmentShader: string;
  91314. VertexShader: string;
  91315. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91316. ReviewUniform(name: string, arr: string[]): string[];
  91317. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91318. constructor(name: string, scene: BABYLON.Scene);
  91319. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  91320. AddAttribute(name: string): CustomMaterial;
  91321. Fragment_Begin(shaderPart: string): CustomMaterial;
  91322. Fragment_Definitions(shaderPart: string): CustomMaterial;
  91323. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  91324. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  91325. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  91326. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  91327. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  91328. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  91329. Vertex_Begin(shaderPart: string): CustomMaterial;
  91330. Vertex_Definitions(shaderPart: string): CustomMaterial;
  91331. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  91332. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  91333. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  91334. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  91335. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  91336. }
  91337. }
  91338. declare module BABYLON {
  91339. export class ShaderAlebdoParts {
  91340. constructor();
  91341. Fragment_Begin: string;
  91342. Fragment_Definitions: string;
  91343. Fragment_MainBegin: string;
  91344. Fragment_Custom_Albedo: string;
  91345. Fragment_Before_Lights: string;
  91346. Fragment_Custom_MetallicRoughness: string;
  91347. Fragment_Custom_MicroSurface: string;
  91348. Fragment_Before_Fog: string;
  91349. Fragment_Custom_Alpha: string;
  91350. Fragment_Before_FragColor: string;
  91351. Vertex_Begin: string;
  91352. Vertex_Definitions: string;
  91353. Vertex_MainBegin: string;
  91354. Vertex_Before_PositionUpdated: string;
  91355. Vertex_Before_NormalUpdated: string;
  91356. Vertex_After_WorldPosComputed: string;
  91357. Vertex_MainEnd: string;
  91358. }
  91359. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  91360. static ShaderIndexer: number;
  91361. CustomParts: ShaderAlebdoParts;
  91362. _isCreatedShader: boolean;
  91363. _createdShaderName: string;
  91364. _customUniform: string[];
  91365. _newUniforms: string[];
  91366. _newUniformInstances: {
  91367. [name: string]: any;
  91368. };
  91369. _newSamplerInstances: {
  91370. [name: string]: BABYLON.Texture;
  91371. };
  91372. _customAttributes: string[];
  91373. FragmentShader: string;
  91374. VertexShader: string;
  91375. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91376. ReviewUniform(name: string, arr: string[]): string[];
  91377. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91378. constructor(name: string, scene: BABYLON.Scene);
  91379. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  91380. AddAttribute(name: string): PBRCustomMaterial;
  91381. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  91382. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  91383. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  91384. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  91385. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  91386. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  91387. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  91388. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  91389. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  91390. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  91391. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  91392. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  91393. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  91394. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  91395. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  91396. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  91397. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  91398. }
  91399. }
  91400. declare module BABYLON {
  91401. /** @hidden */
  91402. export var firePixelShader: {
  91403. name: string;
  91404. shader: string;
  91405. };
  91406. }
  91407. declare module BABYLON {
  91408. /** @hidden */
  91409. export var fireVertexShader: {
  91410. name: string;
  91411. shader: string;
  91412. };
  91413. }
  91414. declare module BABYLON {
  91415. export class FireMaterial extends BABYLON.PushMaterial {
  91416. private _diffuseTexture;
  91417. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91418. private _distortionTexture;
  91419. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91420. private _opacityTexture;
  91421. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91422. diffuseColor: BABYLON.Color3;
  91423. speed: number;
  91424. private _scaledDiffuse;
  91425. private _lastTime;
  91426. constructor(name: string, scene: BABYLON.Scene);
  91427. needAlphaBlending(): boolean;
  91428. needAlphaTesting(): boolean;
  91429. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91430. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91431. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91432. getAnimatables(): BABYLON.IAnimatable[];
  91433. getActiveTextures(): BABYLON.BaseTexture[];
  91434. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91435. getClassName(): string;
  91436. dispose(forceDisposeEffect?: boolean): void;
  91437. clone(name: string): FireMaterial;
  91438. serialize(): any;
  91439. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  91440. }
  91441. }
  91442. declare module BABYLON {
  91443. /** @hidden */
  91444. export var furPixelShader: {
  91445. name: string;
  91446. shader: string;
  91447. };
  91448. }
  91449. declare module BABYLON {
  91450. /** @hidden */
  91451. export var furVertexShader: {
  91452. name: string;
  91453. shader: string;
  91454. };
  91455. }
  91456. declare module BABYLON {
  91457. export class FurMaterial extends BABYLON.PushMaterial {
  91458. private _diffuseTexture;
  91459. diffuseTexture: BABYLON.BaseTexture;
  91460. private _heightTexture;
  91461. heightTexture: BABYLON.BaseTexture;
  91462. diffuseColor: BABYLON.Color3;
  91463. furLength: number;
  91464. furAngle: number;
  91465. furColor: BABYLON.Color3;
  91466. furOffset: number;
  91467. furSpacing: number;
  91468. furGravity: BABYLON.Vector3;
  91469. furSpeed: number;
  91470. furDensity: number;
  91471. furOcclusion: number;
  91472. furTexture: BABYLON.DynamicTexture;
  91473. private _disableLighting;
  91474. disableLighting: boolean;
  91475. private _maxSimultaneousLights;
  91476. maxSimultaneousLights: number;
  91477. highLevelFur: boolean;
  91478. _meshes: BABYLON.AbstractMesh[];
  91479. private _furTime;
  91480. constructor(name: string, scene: BABYLON.Scene);
  91481. get furTime(): number;
  91482. set furTime(furTime: number);
  91483. needAlphaBlending(): boolean;
  91484. needAlphaTesting(): boolean;
  91485. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91486. updateFur(): void;
  91487. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91488. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91489. getAnimatables(): BABYLON.IAnimatable[];
  91490. getActiveTextures(): BABYLON.BaseTexture[];
  91491. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91492. dispose(forceDisposeEffect?: boolean): void;
  91493. clone(name: string): FurMaterial;
  91494. serialize(): any;
  91495. getClassName(): string;
  91496. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  91497. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  91498. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  91499. }
  91500. }
  91501. declare module BABYLON {
  91502. /** @hidden */
  91503. export var gradientPixelShader: {
  91504. name: string;
  91505. shader: string;
  91506. };
  91507. }
  91508. declare module BABYLON {
  91509. /** @hidden */
  91510. export var gradientVertexShader: {
  91511. name: string;
  91512. shader: string;
  91513. };
  91514. }
  91515. declare module BABYLON {
  91516. export class GradientMaterial extends BABYLON.PushMaterial {
  91517. private _maxSimultaneousLights;
  91518. maxSimultaneousLights: number;
  91519. topColor: BABYLON.Color3;
  91520. topColorAlpha: number;
  91521. bottomColor: BABYLON.Color3;
  91522. bottomColorAlpha: number;
  91523. offset: number;
  91524. scale: number;
  91525. smoothness: number;
  91526. private _disableLighting;
  91527. disableLighting: boolean;
  91528. constructor(name: string, scene: BABYLON.Scene);
  91529. needAlphaBlending(): boolean;
  91530. needAlphaTesting(): boolean;
  91531. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91532. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91533. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91534. getAnimatables(): BABYLON.IAnimatable[];
  91535. dispose(forceDisposeEffect?: boolean): void;
  91536. clone(name: string): GradientMaterial;
  91537. serialize(): any;
  91538. getClassName(): string;
  91539. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  91540. }
  91541. }
  91542. declare module BABYLON {
  91543. /** @hidden */
  91544. export var gridPixelShader: {
  91545. name: string;
  91546. shader: string;
  91547. };
  91548. }
  91549. declare module BABYLON {
  91550. /** @hidden */
  91551. export var gridVertexShader: {
  91552. name: string;
  91553. shader: string;
  91554. };
  91555. }
  91556. declare module BABYLON {
  91557. /**
  91558. * The grid materials allows you to wrap any shape with a grid.
  91559. * Colors are customizable.
  91560. */
  91561. export class GridMaterial extends BABYLON.PushMaterial {
  91562. /**
  91563. * Main color of the grid (e.g. between lines)
  91564. */
  91565. mainColor: BABYLON.Color3;
  91566. /**
  91567. * Color of the grid lines.
  91568. */
  91569. lineColor: BABYLON.Color3;
  91570. /**
  91571. * The scale of the grid compared to unit.
  91572. */
  91573. gridRatio: number;
  91574. /**
  91575. * Allows setting an offset for the grid lines.
  91576. */
  91577. gridOffset: BABYLON.Vector3;
  91578. /**
  91579. * The frequency of thicker lines.
  91580. */
  91581. majorUnitFrequency: number;
  91582. /**
  91583. * The visibility of minor units in the grid.
  91584. */
  91585. minorUnitVisibility: number;
  91586. /**
  91587. * The grid opacity outside of the lines.
  91588. */
  91589. opacity: number;
  91590. /**
  91591. * Determine RBG output is premultiplied by alpha value.
  91592. */
  91593. preMultiplyAlpha: boolean;
  91594. private _opacityTexture;
  91595. opacityTexture: BABYLON.BaseTexture;
  91596. private _gridControl;
  91597. /**
  91598. * constructor
  91599. * @param name The name given to the material in order to identify it afterwards.
  91600. * @param scene The scene the material is used in.
  91601. */
  91602. constructor(name: string, scene: BABYLON.Scene);
  91603. /**
  91604. * Returns wehter or not the grid requires alpha blending.
  91605. */
  91606. needAlphaBlending(): boolean;
  91607. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  91608. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91609. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91610. /**
  91611. * Dispose the material and its associated resources.
  91612. * @param forceDisposeEffect will also dispose the used effect when true
  91613. */
  91614. dispose(forceDisposeEffect?: boolean): void;
  91615. clone(name: string): GridMaterial;
  91616. serialize(): any;
  91617. getClassName(): string;
  91618. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  91619. }
  91620. }
  91621. declare module BABYLON {
  91622. /** @hidden */
  91623. export var lavaPixelShader: {
  91624. name: string;
  91625. shader: string;
  91626. };
  91627. }
  91628. declare module BABYLON {
  91629. /** @hidden */
  91630. export var lavaVertexShader: {
  91631. name: string;
  91632. shader: string;
  91633. };
  91634. }
  91635. declare module BABYLON {
  91636. export class LavaMaterial extends BABYLON.PushMaterial {
  91637. private _diffuseTexture;
  91638. diffuseTexture: BABYLON.BaseTexture;
  91639. noiseTexture: BABYLON.BaseTexture;
  91640. fogColor: BABYLON.Color3;
  91641. speed: number;
  91642. movingSpeed: number;
  91643. lowFrequencySpeed: number;
  91644. fogDensity: number;
  91645. private _lastTime;
  91646. diffuseColor: BABYLON.Color3;
  91647. private _disableLighting;
  91648. disableLighting: boolean;
  91649. private _unlit;
  91650. unlit: boolean;
  91651. private _maxSimultaneousLights;
  91652. maxSimultaneousLights: number;
  91653. private _scaledDiffuse;
  91654. constructor(name: string, scene: BABYLON.Scene);
  91655. needAlphaBlending(): boolean;
  91656. needAlphaTesting(): boolean;
  91657. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91658. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91659. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91660. getAnimatables(): BABYLON.IAnimatable[];
  91661. getActiveTextures(): BABYLON.BaseTexture[];
  91662. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91663. dispose(forceDisposeEffect?: boolean): void;
  91664. clone(name: string): LavaMaterial;
  91665. serialize(): any;
  91666. getClassName(): string;
  91667. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  91668. }
  91669. }
  91670. declare module BABYLON {
  91671. /** @hidden */
  91672. export var mixPixelShader: {
  91673. name: string;
  91674. shader: string;
  91675. };
  91676. }
  91677. declare module BABYLON {
  91678. /** @hidden */
  91679. export var mixVertexShader: {
  91680. name: string;
  91681. shader: string;
  91682. };
  91683. }
  91684. declare module BABYLON {
  91685. export class MixMaterial extends BABYLON.PushMaterial {
  91686. /**
  91687. * Mix textures
  91688. */
  91689. private _mixTexture1;
  91690. mixTexture1: BABYLON.BaseTexture;
  91691. private _mixTexture2;
  91692. mixTexture2: BABYLON.BaseTexture;
  91693. /**
  91694. * Diffuse textures
  91695. */
  91696. private _diffuseTexture1;
  91697. diffuseTexture1: BABYLON.Texture;
  91698. private _diffuseTexture2;
  91699. diffuseTexture2: BABYLON.Texture;
  91700. private _diffuseTexture3;
  91701. diffuseTexture3: BABYLON.Texture;
  91702. private _diffuseTexture4;
  91703. diffuseTexture4: BABYLON.Texture;
  91704. private _diffuseTexture5;
  91705. diffuseTexture5: BABYLON.Texture;
  91706. private _diffuseTexture6;
  91707. diffuseTexture6: BABYLON.Texture;
  91708. private _diffuseTexture7;
  91709. diffuseTexture7: BABYLON.Texture;
  91710. private _diffuseTexture8;
  91711. diffuseTexture8: BABYLON.Texture;
  91712. /**
  91713. * Uniforms
  91714. */
  91715. diffuseColor: BABYLON.Color3;
  91716. specularColor: BABYLON.Color3;
  91717. specularPower: number;
  91718. private _disableLighting;
  91719. disableLighting: boolean;
  91720. private _maxSimultaneousLights;
  91721. maxSimultaneousLights: number;
  91722. constructor(name: string, scene: BABYLON.Scene);
  91723. needAlphaBlending(): boolean;
  91724. needAlphaTesting(): boolean;
  91725. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91726. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91727. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91728. getAnimatables(): BABYLON.IAnimatable[];
  91729. getActiveTextures(): BABYLON.BaseTexture[];
  91730. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91731. dispose(forceDisposeEffect?: boolean): void;
  91732. clone(name: string): MixMaterial;
  91733. serialize(): any;
  91734. getClassName(): string;
  91735. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  91736. }
  91737. }
  91738. declare module BABYLON {
  91739. /** @hidden */
  91740. export var normalPixelShader: {
  91741. name: string;
  91742. shader: string;
  91743. };
  91744. }
  91745. declare module BABYLON {
  91746. /** @hidden */
  91747. export var normalVertexShader: {
  91748. name: string;
  91749. shader: string;
  91750. };
  91751. }
  91752. declare module BABYLON {
  91753. export class NormalMaterial extends BABYLON.PushMaterial {
  91754. private _diffuseTexture;
  91755. diffuseTexture: BABYLON.BaseTexture;
  91756. diffuseColor: BABYLON.Color3;
  91757. private _disableLighting;
  91758. disableLighting: boolean;
  91759. private _maxSimultaneousLights;
  91760. maxSimultaneousLights: number;
  91761. constructor(name: string, scene: BABYLON.Scene);
  91762. needAlphaBlending(): boolean;
  91763. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  91764. needAlphaTesting(): boolean;
  91765. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91766. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91767. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91768. getAnimatables(): BABYLON.IAnimatable[];
  91769. getActiveTextures(): BABYLON.BaseTexture[];
  91770. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91771. dispose(forceDisposeEffect?: boolean): void;
  91772. clone(name: string): NormalMaterial;
  91773. serialize(): any;
  91774. getClassName(): string;
  91775. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  91776. }
  91777. }
  91778. declare module BABYLON {
  91779. /** @hidden */
  91780. export var shadowOnlyPixelShader: {
  91781. name: string;
  91782. shader: string;
  91783. };
  91784. }
  91785. declare module BABYLON {
  91786. /** @hidden */
  91787. export var shadowOnlyVertexShader: {
  91788. name: string;
  91789. shader: string;
  91790. };
  91791. }
  91792. declare module BABYLON {
  91793. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  91794. private _activeLight;
  91795. private _needAlphaBlending;
  91796. constructor(name: string, scene: BABYLON.Scene);
  91797. shadowColor: BABYLON.Color3;
  91798. needAlphaBlending(): boolean;
  91799. needAlphaTesting(): boolean;
  91800. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91801. get activeLight(): BABYLON.IShadowLight;
  91802. set activeLight(light: BABYLON.IShadowLight);
  91803. private _getFirstShadowLightForMesh;
  91804. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91805. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91806. clone(name: string): ShadowOnlyMaterial;
  91807. serialize(): any;
  91808. getClassName(): string;
  91809. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  91810. }
  91811. }
  91812. declare module BABYLON {
  91813. /** @hidden */
  91814. export var simplePixelShader: {
  91815. name: string;
  91816. shader: string;
  91817. };
  91818. }
  91819. declare module BABYLON {
  91820. /** @hidden */
  91821. export var simpleVertexShader: {
  91822. name: string;
  91823. shader: string;
  91824. };
  91825. }
  91826. declare module BABYLON {
  91827. export class SimpleMaterial extends BABYLON.PushMaterial {
  91828. private _diffuseTexture;
  91829. diffuseTexture: BABYLON.BaseTexture;
  91830. diffuseColor: BABYLON.Color3;
  91831. private _disableLighting;
  91832. disableLighting: boolean;
  91833. private _maxSimultaneousLights;
  91834. maxSimultaneousLights: number;
  91835. constructor(name: string, scene: BABYLON.Scene);
  91836. needAlphaBlending(): boolean;
  91837. needAlphaTesting(): boolean;
  91838. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91839. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91840. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91841. getAnimatables(): BABYLON.IAnimatable[];
  91842. getActiveTextures(): BABYLON.BaseTexture[];
  91843. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91844. dispose(forceDisposeEffect?: boolean): void;
  91845. clone(name: string): SimpleMaterial;
  91846. serialize(): any;
  91847. getClassName(): string;
  91848. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  91849. }
  91850. }
  91851. declare module BABYLON {
  91852. /** @hidden */
  91853. export var skyPixelShader: {
  91854. name: string;
  91855. shader: string;
  91856. };
  91857. }
  91858. declare module BABYLON {
  91859. /** @hidden */
  91860. export var skyVertexShader: {
  91861. name: string;
  91862. shader: string;
  91863. };
  91864. }
  91865. declare module BABYLON {
  91866. /**
  91867. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  91868. * @see https://doc.babylonjs.com/extensions/sky
  91869. */
  91870. export class SkyMaterial extends BABYLON.PushMaterial {
  91871. /**
  91872. * Defines the overall luminance of sky in interval ]0, 1[.
  91873. */
  91874. luminance: number;
  91875. /**
  91876. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  91877. */
  91878. turbidity: number;
  91879. /**
  91880. * Defines the sky appearance (light intensity).
  91881. */
  91882. rayleigh: number;
  91883. /**
  91884. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  91885. */
  91886. mieCoefficient: number;
  91887. /**
  91888. * Defines the amount of haze particles following the Mie scattering theory.
  91889. */
  91890. mieDirectionalG: number;
  91891. /**
  91892. * Defines the distance of the sun according to the active scene camera.
  91893. */
  91894. distance: number;
  91895. /**
  91896. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  91897. * "inclined".
  91898. */
  91899. inclination: number;
  91900. /**
  91901. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  91902. * an object direction and a reference direction.
  91903. */
  91904. azimuth: number;
  91905. /**
  91906. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  91907. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  91908. */
  91909. sunPosition: BABYLON.Vector3;
  91910. /**
  91911. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  91912. * .sunPosition property.
  91913. */
  91914. useSunPosition: boolean;
  91915. /**
  91916. * Defines an offset vector used to get a horizon offset.
  91917. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  91918. */
  91919. cameraOffset: BABYLON.Vector3;
  91920. private _cameraPosition;
  91921. /**
  91922. * Instantiates a new sky material.
  91923. * This material allows to create dynamic and texture free
  91924. * effects for skyboxes by taking care of the atmosphere state.
  91925. * @see https://doc.babylonjs.com/extensions/sky
  91926. * @param name Define the name of the material in the scene
  91927. * @param scene Define the scene the material belong to
  91928. */
  91929. constructor(name: string, scene: BABYLON.Scene);
  91930. /**
  91931. * Specifies if the material will require alpha blending
  91932. * @returns a boolean specifying if alpha blending is needed
  91933. */
  91934. needAlphaBlending(): boolean;
  91935. /**
  91936. * Specifies if this material should be rendered in alpha test mode
  91937. * @returns false as the sky material doesn't need alpha testing.
  91938. */
  91939. needAlphaTesting(): boolean;
  91940. /**
  91941. * Get the texture used for alpha test purpose.
  91942. * @returns null as the sky material has no texture.
  91943. */
  91944. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91945. /**
  91946. * Get if the submesh is ready to be used and all its information available.
  91947. * Child classes can use it to update shaders
  91948. * @param mesh defines the mesh to check
  91949. * @param subMesh defines which submesh to check
  91950. * @param useInstances specifies that instances should be used
  91951. * @returns a boolean indicating that the submesh is ready or not
  91952. */
  91953. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91954. /**
  91955. * Binds the submesh to this material by preparing the effect and shader to draw
  91956. * @param world defines the world transformation matrix
  91957. * @param mesh defines the mesh containing the submesh
  91958. * @param subMesh defines the submesh to bind the material to
  91959. */
  91960. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91961. /**
  91962. * Get the list of animatables in the material.
  91963. * @returns the list of animatables object used in the material
  91964. */
  91965. getAnimatables(): BABYLON.IAnimatable[];
  91966. /**
  91967. * Disposes the material
  91968. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91969. */
  91970. dispose(forceDisposeEffect?: boolean): void;
  91971. /**
  91972. * Makes a duplicate of the material, and gives it a new name
  91973. * @param name defines the new name for the duplicated material
  91974. * @returns the cloned material
  91975. */
  91976. clone(name: string): SkyMaterial;
  91977. /**
  91978. * Serializes this material in a JSON representation
  91979. * @returns the serialized material object
  91980. */
  91981. serialize(): any;
  91982. /**
  91983. * Gets the current class name of the material e.g. "SkyMaterial"
  91984. * Mainly use in serialization.
  91985. * @returns the class name
  91986. */
  91987. getClassName(): string;
  91988. /**
  91989. * Creates a sky material from parsed material data
  91990. * @param source defines the JSON representation of the material
  91991. * @param scene defines the hosting scene
  91992. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91993. * @returns a new sky material
  91994. */
  91995. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  91996. }
  91997. }
  91998. declare module BABYLON {
  91999. /** @hidden */
  92000. export var terrainPixelShader: {
  92001. name: string;
  92002. shader: string;
  92003. };
  92004. }
  92005. declare module BABYLON {
  92006. /** @hidden */
  92007. export var terrainVertexShader: {
  92008. name: string;
  92009. shader: string;
  92010. };
  92011. }
  92012. declare module BABYLON {
  92013. export class TerrainMaterial extends BABYLON.PushMaterial {
  92014. private _mixTexture;
  92015. mixTexture: BABYLON.BaseTexture;
  92016. private _diffuseTexture1;
  92017. diffuseTexture1: BABYLON.Texture;
  92018. private _diffuseTexture2;
  92019. diffuseTexture2: BABYLON.Texture;
  92020. private _diffuseTexture3;
  92021. diffuseTexture3: BABYLON.Texture;
  92022. private _bumpTexture1;
  92023. bumpTexture1: BABYLON.Texture;
  92024. private _bumpTexture2;
  92025. bumpTexture2: BABYLON.Texture;
  92026. private _bumpTexture3;
  92027. bumpTexture3: BABYLON.Texture;
  92028. diffuseColor: BABYLON.Color3;
  92029. specularColor: BABYLON.Color3;
  92030. specularPower: number;
  92031. private _disableLighting;
  92032. disableLighting: boolean;
  92033. private _maxSimultaneousLights;
  92034. maxSimultaneousLights: number;
  92035. constructor(name: string, scene: BABYLON.Scene);
  92036. needAlphaBlending(): boolean;
  92037. needAlphaTesting(): boolean;
  92038. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92039. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92040. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92041. getAnimatables(): BABYLON.IAnimatable[];
  92042. getActiveTextures(): BABYLON.BaseTexture[];
  92043. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92044. dispose(forceDisposeEffect?: boolean): void;
  92045. clone(name: string): TerrainMaterial;
  92046. serialize(): any;
  92047. getClassName(): string;
  92048. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  92049. }
  92050. }
  92051. declare module BABYLON {
  92052. /** @hidden */
  92053. export var triplanarPixelShader: {
  92054. name: string;
  92055. shader: string;
  92056. };
  92057. }
  92058. declare module BABYLON {
  92059. /** @hidden */
  92060. export var triplanarVertexShader: {
  92061. name: string;
  92062. shader: string;
  92063. };
  92064. }
  92065. declare module BABYLON {
  92066. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  92067. mixTexture: BABYLON.BaseTexture;
  92068. private _diffuseTextureX;
  92069. diffuseTextureX: BABYLON.BaseTexture;
  92070. private _diffuseTextureY;
  92071. diffuseTextureY: BABYLON.BaseTexture;
  92072. private _diffuseTextureZ;
  92073. diffuseTextureZ: BABYLON.BaseTexture;
  92074. private _normalTextureX;
  92075. normalTextureX: BABYLON.BaseTexture;
  92076. private _normalTextureY;
  92077. normalTextureY: BABYLON.BaseTexture;
  92078. private _normalTextureZ;
  92079. normalTextureZ: BABYLON.BaseTexture;
  92080. tileSize: number;
  92081. diffuseColor: BABYLON.Color3;
  92082. specularColor: BABYLON.Color3;
  92083. specularPower: number;
  92084. private _disableLighting;
  92085. disableLighting: boolean;
  92086. private _maxSimultaneousLights;
  92087. maxSimultaneousLights: number;
  92088. constructor(name: string, scene: BABYLON.Scene);
  92089. needAlphaBlending(): boolean;
  92090. needAlphaTesting(): boolean;
  92091. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92092. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92093. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92094. getAnimatables(): BABYLON.IAnimatable[];
  92095. getActiveTextures(): BABYLON.BaseTexture[];
  92096. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92097. dispose(forceDisposeEffect?: boolean): void;
  92098. clone(name: string): TriPlanarMaterial;
  92099. serialize(): any;
  92100. getClassName(): string;
  92101. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  92102. }
  92103. }
  92104. declare module BABYLON {
  92105. /** @hidden */
  92106. export var waterPixelShader: {
  92107. name: string;
  92108. shader: string;
  92109. };
  92110. }
  92111. declare module BABYLON {
  92112. /** @hidden */
  92113. export var waterVertexShader: {
  92114. name: string;
  92115. shader: string;
  92116. };
  92117. }
  92118. declare module BABYLON {
  92119. export class WaterMaterial extends BABYLON.PushMaterial {
  92120. renderTargetSize: BABYLON.Vector2;
  92121. private _bumpTexture;
  92122. bumpTexture: BABYLON.BaseTexture;
  92123. diffuseColor: BABYLON.Color3;
  92124. specularColor: BABYLON.Color3;
  92125. specularPower: number;
  92126. private _disableLighting;
  92127. disableLighting: boolean;
  92128. private _maxSimultaneousLights;
  92129. maxSimultaneousLights: number;
  92130. /**
  92131. * Defines the wind force.
  92132. */
  92133. windForce: number;
  92134. /**
  92135. * Defines the direction of the wind in the plane (X, Z).
  92136. */
  92137. windDirection: BABYLON.Vector2;
  92138. /**
  92139. * Defines the height of the waves.
  92140. */
  92141. waveHeight: number;
  92142. /**
  92143. * Defines the bump height related to the bump map.
  92144. */
  92145. bumpHeight: number;
  92146. /**
  92147. * Defines wether or not: to add a smaller moving bump to less steady waves.
  92148. */
  92149. private _bumpSuperimpose;
  92150. bumpSuperimpose: boolean;
  92151. /**
  92152. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  92153. */
  92154. private _fresnelSeparate;
  92155. fresnelSeparate: boolean;
  92156. /**
  92157. * Defines wether or not bump Wwves modify the reflection.
  92158. */
  92159. private _bumpAffectsReflection;
  92160. bumpAffectsReflection: boolean;
  92161. /**
  92162. * Defines the water color blended with the refraction (near).
  92163. */
  92164. waterColor: BABYLON.Color3;
  92165. /**
  92166. * Defines the blend factor related to the water color.
  92167. */
  92168. colorBlendFactor: number;
  92169. /**
  92170. * Defines the water color blended with the reflection (far).
  92171. */
  92172. waterColor2: BABYLON.Color3;
  92173. /**
  92174. * Defines the blend factor related to the water color (reflection, far).
  92175. */
  92176. colorBlendFactor2: number;
  92177. /**
  92178. * Defines the maximum length of a wave.
  92179. */
  92180. waveLength: number;
  92181. /**
  92182. * Defines the waves speed.
  92183. */
  92184. waveSpeed: number;
  92185. /**
  92186. * 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.
  92187. */
  92188. waveCount: number;
  92189. /**
  92190. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  92191. * will avoid calculating useless pixels in the pixel shader of the water material.
  92192. */
  92193. disableClipPlane: boolean;
  92194. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  92195. private _mesh;
  92196. private _refractionRTT;
  92197. private _reflectionRTT;
  92198. private _reflectionTransform;
  92199. private _lastTime;
  92200. private _lastDeltaTime;
  92201. private _useLogarithmicDepth;
  92202. private _waitingRenderList;
  92203. private _imageProcessingConfiguration;
  92204. private _imageProcessingObserver;
  92205. /**
  92206. * Gets a boolean indicating that current material needs to register RTT
  92207. */
  92208. get hasRenderTargetTextures(): boolean;
  92209. /**
  92210. * Constructor
  92211. */
  92212. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  92213. get useLogarithmicDepth(): boolean;
  92214. set useLogarithmicDepth(value: boolean);
  92215. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92216. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92217. addToRenderList(node: any): void;
  92218. enableRenderTargets(enable: boolean): void;
  92219. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  92220. get renderTargetsEnabled(): boolean;
  92221. needAlphaBlending(): boolean;
  92222. needAlphaTesting(): boolean;
  92223. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92224. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92225. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92226. private _createRenderTargets;
  92227. getAnimatables(): BABYLON.IAnimatable[];
  92228. getActiveTextures(): BABYLON.BaseTexture[];
  92229. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92230. dispose(forceDisposeEffect?: boolean): void;
  92231. clone(name: string): WaterMaterial;
  92232. serialize(): any;
  92233. getClassName(): string;
  92234. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  92235. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  92236. }
  92237. }
  92238. declare module BABYLON {
  92239. /** @hidden */
  92240. export var asciiartPixelShader: {
  92241. name: string;
  92242. shader: string;
  92243. };
  92244. }
  92245. declare module BABYLON {
  92246. /**
  92247. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  92248. *
  92249. * It basically takes care rendering the font front the given font size to a texture.
  92250. * This is used later on in the postprocess.
  92251. */
  92252. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  92253. private _font;
  92254. private _text;
  92255. private _charSize;
  92256. /**
  92257. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92258. */
  92259. get charSize(): number;
  92260. /**
  92261. * Create a new instance of the Ascii Art FontTexture class
  92262. * @param name the name of the texture
  92263. * @param font the font to use, use the W3C CSS notation
  92264. * @param text the caracter set to use in the rendering.
  92265. * @param scene the scene that owns the texture
  92266. */
  92267. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92268. /**
  92269. * Gets the max char width of a font.
  92270. * @param font the font to use, use the W3C CSS notation
  92271. * @return the max char width
  92272. */
  92273. private getFontWidth;
  92274. /**
  92275. * Gets the max char height of a font.
  92276. * @param font the font to use, use the W3C CSS notation
  92277. * @return the max char height
  92278. */
  92279. private getFontHeight;
  92280. /**
  92281. * Clones the current AsciiArtTexture.
  92282. * @return the clone of the texture.
  92283. */
  92284. clone(): AsciiArtFontTexture;
  92285. /**
  92286. * Parses a json object representing the texture and returns an instance of it.
  92287. * @param source the source JSON representation
  92288. * @param scene the scene to create the texture for
  92289. * @return the parsed texture
  92290. */
  92291. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  92292. }
  92293. /**
  92294. * Option available in the Ascii Art Post Process.
  92295. */
  92296. export interface IAsciiArtPostProcessOptions {
  92297. /**
  92298. * The font to use following the w3c font definition.
  92299. */
  92300. font?: string;
  92301. /**
  92302. * The character set to use in the postprocess.
  92303. */
  92304. characterSet?: string;
  92305. /**
  92306. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92307. * This number is defined between 0 and 1;
  92308. */
  92309. mixToTile?: number;
  92310. /**
  92311. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92312. * This number is defined between 0 and 1;
  92313. */
  92314. mixToNormal?: number;
  92315. }
  92316. /**
  92317. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  92318. *
  92319. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92320. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  92321. */
  92322. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  92323. /**
  92324. * The font texture used to render the char in the post process.
  92325. */
  92326. private _asciiArtFontTexture;
  92327. /**
  92328. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92329. * This number is defined between 0 and 1;
  92330. */
  92331. mixToTile: number;
  92332. /**
  92333. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92334. * This number is defined between 0 and 1;
  92335. */
  92336. mixToNormal: number;
  92337. /**
  92338. * Instantiates a new Ascii Art Post Process.
  92339. * @param name the name to give to the postprocess
  92340. * @camera the camera to apply the post process to.
  92341. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  92342. */
  92343. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  92344. }
  92345. }
  92346. declare module BABYLON {
  92347. /** @hidden */
  92348. export var digitalrainPixelShader: {
  92349. name: string;
  92350. shader: string;
  92351. };
  92352. }
  92353. declare module BABYLON {
  92354. /**
  92355. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  92356. *
  92357. * It basically takes care rendering the font front the given font size to a texture.
  92358. * This is used later on in the postprocess.
  92359. */
  92360. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  92361. private _font;
  92362. private _text;
  92363. private _charSize;
  92364. /**
  92365. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92366. */
  92367. get charSize(): number;
  92368. /**
  92369. * Create a new instance of the Digital Rain FontTexture class
  92370. * @param name the name of the texture
  92371. * @param font the font to use, use the W3C CSS notation
  92372. * @param text the caracter set to use in the rendering.
  92373. * @param scene the scene that owns the texture
  92374. */
  92375. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92376. /**
  92377. * Gets the max char width of a font.
  92378. * @param font the font to use, use the W3C CSS notation
  92379. * @return the max char width
  92380. */
  92381. private getFontWidth;
  92382. /**
  92383. * Gets the max char height of a font.
  92384. * @param font the font to use, use the W3C CSS notation
  92385. * @return the max char height
  92386. */
  92387. private getFontHeight;
  92388. /**
  92389. * Clones the current DigitalRainFontTexture.
  92390. * @return the clone of the texture.
  92391. */
  92392. clone(): DigitalRainFontTexture;
  92393. /**
  92394. * Parses a json object representing the texture and returns an instance of it.
  92395. * @param source the source JSON representation
  92396. * @param scene the scene to create the texture for
  92397. * @return the parsed texture
  92398. */
  92399. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  92400. }
  92401. /**
  92402. * Option available in the Digital Rain Post Process.
  92403. */
  92404. export interface IDigitalRainPostProcessOptions {
  92405. /**
  92406. * The font to use following the w3c font definition.
  92407. */
  92408. font?: string;
  92409. /**
  92410. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92411. * This number is defined between 0 and 1;
  92412. */
  92413. mixToTile?: number;
  92414. /**
  92415. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92416. * This number is defined between 0 and 1;
  92417. */
  92418. mixToNormal?: number;
  92419. }
  92420. /**
  92421. * DigitalRainPostProcess helps rendering everithing in digital rain.
  92422. *
  92423. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92424. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  92425. */
  92426. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  92427. /**
  92428. * The font texture used to render the char in the post process.
  92429. */
  92430. private _digitalRainFontTexture;
  92431. /**
  92432. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92433. * This number is defined between 0 and 1;
  92434. */
  92435. mixToTile: number;
  92436. /**
  92437. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92438. * This number is defined between 0 and 1;
  92439. */
  92440. mixToNormal: number;
  92441. /**
  92442. * Instantiates a new Digital Rain Post Process.
  92443. * @param name the name to give to the postprocess
  92444. * @camera the camera to apply the post process to.
  92445. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  92446. */
  92447. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  92448. }
  92449. }
  92450. declare module BABYLON {
  92451. /** @hidden */
  92452. export var brickProceduralTexturePixelShader: {
  92453. name: string;
  92454. shader: string;
  92455. };
  92456. }
  92457. declare module BABYLON {
  92458. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  92459. private _numberOfBricksHeight;
  92460. private _numberOfBricksWidth;
  92461. private _jointColor;
  92462. private _brickColor;
  92463. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92464. updateShaderUniforms(): void;
  92465. get numberOfBricksHeight(): number;
  92466. set numberOfBricksHeight(value: number);
  92467. get numberOfBricksWidth(): number;
  92468. set numberOfBricksWidth(value: number);
  92469. get jointColor(): BABYLON.Color3;
  92470. set jointColor(value: BABYLON.Color3);
  92471. get brickColor(): BABYLON.Color3;
  92472. set brickColor(value: BABYLON.Color3);
  92473. /**
  92474. * Serializes this brick procedural texture
  92475. * @returns a serialized brick procedural texture object
  92476. */
  92477. serialize(): any;
  92478. /**
  92479. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  92480. * @param parsedTexture defines parsed texture data
  92481. * @param scene defines the current scene
  92482. * @param rootUrl defines the root URL containing brick procedural texture information
  92483. * @returns a parsed Brick Procedural BABYLON.Texture
  92484. */
  92485. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  92486. }
  92487. }
  92488. declare module BABYLON {
  92489. /** @hidden */
  92490. export var cloudProceduralTexturePixelShader: {
  92491. name: string;
  92492. shader: string;
  92493. };
  92494. }
  92495. declare module BABYLON {
  92496. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  92497. private _skyColor;
  92498. private _cloudColor;
  92499. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92500. updateShaderUniforms(): void;
  92501. get skyColor(): BABYLON.Color4;
  92502. set skyColor(value: BABYLON.Color4);
  92503. get cloudColor(): BABYLON.Color4;
  92504. set cloudColor(value: BABYLON.Color4);
  92505. /**
  92506. * Serializes this cloud procedural texture
  92507. * @returns a serialized cloud procedural texture object
  92508. */
  92509. serialize(): any;
  92510. /**
  92511. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  92512. * @param parsedTexture defines parsed texture data
  92513. * @param scene defines the current scene
  92514. * @param rootUrl defines the root URL containing cloud procedural texture information
  92515. * @returns a parsed Cloud Procedural BABYLON.Texture
  92516. */
  92517. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  92518. }
  92519. }
  92520. declare module BABYLON {
  92521. /** @hidden */
  92522. export var fireProceduralTexturePixelShader: {
  92523. name: string;
  92524. shader: string;
  92525. };
  92526. }
  92527. declare module BABYLON {
  92528. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  92529. private _time;
  92530. private _speed;
  92531. private _autoGenerateTime;
  92532. private _fireColors;
  92533. private _alphaThreshold;
  92534. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92535. updateShaderUniforms(): void;
  92536. render(useCameraPostProcess?: boolean): void;
  92537. static get PurpleFireColors(): BABYLON.Color3[];
  92538. static get GreenFireColors(): BABYLON.Color3[];
  92539. static get RedFireColors(): BABYLON.Color3[];
  92540. static get BlueFireColors(): BABYLON.Color3[];
  92541. get autoGenerateTime(): boolean;
  92542. set autoGenerateTime(value: boolean);
  92543. get fireColors(): BABYLON.Color3[];
  92544. set fireColors(value: BABYLON.Color3[]);
  92545. get time(): number;
  92546. set time(value: number);
  92547. get speed(): BABYLON.Vector2;
  92548. set speed(value: BABYLON.Vector2);
  92549. get alphaThreshold(): number;
  92550. set alphaThreshold(value: number);
  92551. /**
  92552. * Serializes this fire procedural texture
  92553. * @returns a serialized fire procedural texture object
  92554. */
  92555. serialize(): any;
  92556. /**
  92557. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  92558. * @param parsedTexture defines parsed texture data
  92559. * @param scene defines the current scene
  92560. * @param rootUrl defines the root URL containing fire procedural texture information
  92561. * @returns a parsed Fire Procedural BABYLON.Texture
  92562. */
  92563. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  92564. }
  92565. }
  92566. declare module BABYLON {
  92567. /** @hidden */
  92568. export var grassProceduralTexturePixelShader: {
  92569. name: string;
  92570. shader: string;
  92571. };
  92572. }
  92573. declare module BABYLON {
  92574. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  92575. private _grassColors;
  92576. private _groundColor;
  92577. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92578. updateShaderUniforms(): void;
  92579. get grassColors(): BABYLON.Color3[];
  92580. set grassColors(value: BABYLON.Color3[]);
  92581. get groundColor(): BABYLON.Color3;
  92582. set groundColor(value: BABYLON.Color3);
  92583. /**
  92584. * Serializes this grass procedural texture
  92585. * @returns a serialized grass procedural texture object
  92586. */
  92587. serialize(): any;
  92588. /**
  92589. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  92590. * @param parsedTexture defines parsed texture data
  92591. * @param scene defines the current scene
  92592. * @param rootUrl defines the root URL containing grass procedural texture information
  92593. * @returns a parsed Grass Procedural BABYLON.Texture
  92594. */
  92595. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  92596. }
  92597. }
  92598. declare module BABYLON {
  92599. /** @hidden */
  92600. export var marbleProceduralTexturePixelShader: {
  92601. name: string;
  92602. shader: string;
  92603. };
  92604. }
  92605. declare module BABYLON {
  92606. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  92607. private _numberOfTilesHeight;
  92608. private _numberOfTilesWidth;
  92609. private _amplitude;
  92610. private _jointColor;
  92611. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92612. updateShaderUniforms(): void;
  92613. get numberOfTilesHeight(): number;
  92614. set numberOfTilesHeight(value: number);
  92615. get amplitude(): number;
  92616. set amplitude(value: number);
  92617. get numberOfTilesWidth(): number;
  92618. set numberOfTilesWidth(value: number);
  92619. get jointColor(): BABYLON.Color3;
  92620. set jointColor(value: BABYLON.Color3);
  92621. /**
  92622. * Serializes this marble procedural texture
  92623. * @returns a serialized marble procedural texture object
  92624. */
  92625. serialize(): any;
  92626. /**
  92627. * Creates a Marble Procedural BABYLON.Texture from parsed marble 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 marble procedural texture information
  92631. * @returns a parsed Marble Procedural BABYLON.Texture
  92632. */
  92633. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  92634. }
  92635. }
  92636. declare module BABYLON {
  92637. /** @hidden */
  92638. export var normalMapProceduralTexturePixelShader: {
  92639. name: string;
  92640. shader: string;
  92641. };
  92642. }
  92643. declare module BABYLON {
  92644. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  92645. private _baseTexture;
  92646. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92647. updateShaderUniforms(): void;
  92648. render(useCameraPostProcess?: boolean): void;
  92649. resize(size: any, generateMipMaps: any): void;
  92650. isReady(): boolean;
  92651. get baseTexture(): BABYLON.Texture;
  92652. set baseTexture(texture: BABYLON.Texture);
  92653. /**
  92654. * Serializes this normal map procedural texture
  92655. * @returns a serialized normal map procedural texture object
  92656. */
  92657. serialize(): any;
  92658. /**
  92659. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  92660. * @param parsedTexture defines parsed texture data
  92661. * @param scene defines the current scene
  92662. * @param rootUrl defines the root URL containing normal map procedural texture information
  92663. * @returns a parsed Normal Map Procedural BABYLON.Texture
  92664. */
  92665. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  92666. }
  92667. }
  92668. declare module BABYLON {
  92669. /** @hidden */
  92670. export var perlinNoiseProceduralTexturePixelShader: {
  92671. name: string;
  92672. shader: string;
  92673. };
  92674. }
  92675. declare module BABYLON {
  92676. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  92677. time: number;
  92678. timeScale: number;
  92679. translationSpeed: number;
  92680. private _currentTranslation;
  92681. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92682. updateShaderUniforms(): void;
  92683. render(useCameraPostProcess?: boolean): void;
  92684. resize(size: any, generateMipMaps: any): void;
  92685. /**
  92686. * Serializes this perlin noise procedural texture
  92687. * @returns a serialized perlin noise procedural texture object
  92688. */
  92689. serialize(): any;
  92690. /**
  92691. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  92692. * @param parsedTexture defines parsed texture data
  92693. * @param scene defines the current scene
  92694. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  92695. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  92696. */
  92697. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  92698. }
  92699. }
  92700. declare module BABYLON {
  92701. /** @hidden */
  92702. export var roadProceduralTexturePixelShader: {
  92703. name: string;
  92704. shader: string;
  92705. };
  92706. }
  92707. declare module BABYLON {
  92708. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  92709. private _roadColor;
  92710. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92711. updateShaderUniforms(): void;
  92712. get roadColor(): BABYLON.Color3;
  92713. set roadColor(value: BABYLON.Color3);
  92714. /**
  92715. * Serializes this road procedural texture
  92716. * @returns a serialized road procedural texture object
  92717. */
  92718. serialize(): any;
  92719. /**
  92720. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  92721. * @param parsedTexture defines parsed texture data
  92722. * @param scene defines the current scene
  92723. * @param rootUrl defines the root URL containing road procedural texture information
  92724. * @returns a parsed Road Procedural BABYLON.Texture
  92725. */
  92726. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  92727. }
  92728. }
  92729. declare module BABYLON {
  92730. /** @hidden */
  92731. export var starfieldProceduralTexturePixelShader: {
  92732. name: string;
  92733. shader: string;
  92734. };
  92735. }
  92736. declare module BABYLON {
  92737. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  92738. private _time;
  92739. private _alpha;
  92740. private _beta;
  92741. private _zoom;
  92742. private _formuparam;
  92743. private _stepsize;
  92744. private _tile;
  92745. private _brightness;
  92746. private _darkmatter;
  92747. private _distfading;
  92748. private _saturation;
  92749. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92750. updateShaderUniforms(): void;
  92751. get time(): number;
  92752. set time(value: number);
  92753. get alpha(): number;
  92754. set alpha(value: number);
  92755. get beta(): number;
  92756. set beta(value: number);
  92757. get formuparam(): number;
  92758. set formuparam(value: number);
  92759. get stepsize(): number;
  92760. set stepsize(value: number);
  92761. get zoom(): number;
  92762. set zoom(value: number);
  92763. get tile(): number;
  92764. set tile(value: number);
  92765. get brightness(): number;
  92766. set brightness(value: number);
  92767. get darkmatter(): number;
  92768. set darkmatter(value: number);
  92769. get distfading(): number;
  92770. set distfading(value: number);
  92771. get saturation(): number;
  92772. set saturation(value: number);
  92773. /**
  92774. * Serializes this starfield procedural texture
  92775. * @returns a serialized starfield procedural texture object
  92776. */
  92777. serialize(): any;
  92778. /**
  92779. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  92780. * @param parsedTexture defines parsed texture data
  92781. * @param scene defines the current scene
  92782. * @param rootUrl defines the root URL containing startfield procedural texture information
  92783. * @returns a parsed Starfield Procedural BABYLON.Texture
  92784. */
  92785. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  92786. }
  92787. }
  92788. declare module BABYLON {
  92789. /** @hidden */
  92790. export var woodProceduralTexturePixelShader: {
  92791. name: string;
  92792. shader: string;
  92793. };
  92794. }
  92795. declare module BABYLON {
  92796. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  92797. private _ampScale;
  92798. private _woodColor;
  92799. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92800. updateShaderUniforms(): void;
  92801. get ampScale(): number;
  92802. set ampScale(value: number);
  92803. get woodColor(): BABYLON.Color3;
  92804. set woodColor(value: BABYLON.Color3);
  92805. /**
  92806. * Serializes this wood procedural texture
  92807. * @returns a serialized wood procedural texture object
  92808. */
  92809. serialize(): any;
  92810. /**
  92811. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  92812. * @param parsedTexture defines parsed texture data
  92813. * @param scene defines the current scene
  92814. * @param rootUrl defines the root URL containing wood procedural texture information
  92815. * @returns a parsed Wood Procedural BABYLON.Texture
  92816. */
  92817. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  92818. }
  92819. }